This is a driver for the mar345 detector from Marresearch GmbH. It inherits from ADDriver and implements many of the parameters in ADStdDriverParams.h. It also implements a number of parameters that are specific to the mar345 detector.
The interface to the detector is via a TCP/IP socket interface to the mar345dtb program that Marresearch provides. The mar345dtb program must be started before the areaDetector software is started.
mar345dtb must be configured to accepts commands on a TCP/IP socket port. This is done by editing the file /home/mar345/tables/config.xxx (where xxx is the serial number of that detector) and editing the COMMAND line to the following format:
COMMAND PORT 5001
where 5001 is the TCP/IP port to use. Any high port number can be used, but it must agree with the one specified in the areaDetector mar345Config command described below.
The mar345dtb program saves the data to disk as compressed binary files. The areaDetector software reads these disk files in order to read the data, because mar345dtb does not provide another mechanism to access the data.
The following table describes how the mar345 driver implements some of the standard driver parameters.
| Implementation of Parameters in ADStdDriverParams.h and EPICS Record Definitions in ADBase.template and NDFile.template | ||
| Enum name | EPICS record name | Description |
|---|---|---|
| ADAcquire | $(P$(R)Acquire |
Setting this to 1 starts an acquisition sequence. If ADNumImages is greater than 1 then it acquires multiple
frames. For each frame it does the following:
|
| ADNumImages | $(P$(R)NumImages | Controls the number of images to acquire when ADImageMode is ADImageMultiple. |
| ADAcquirePeriod | $(P$(R)AcquirePeriod | Controls the period between images when ADImageMode is ADImageMultiple or ADImageContinuous. If this is greater than the acquisition time plus readout overhead then the driver will wait until the period has elapsed before starting the next acquisition. |
| ADFilePath | $(P$(R)FilePath | Controls the path for saving images. It must be a valid path for mar345dtb and for the areaDetector driver, which is normally running in an EPICS IOC. If mar345dtb and the EPICS IOC are not running on the same machine then soft links will typically be used to make the paths look identical. |
| ADFileFormat | $(P)$(R)FileFormat | mar345 only supports mar345 format binary files. |
| ADStatus | $(P)$(R)DetectorState_RBV | mar345 replaces the state strings with the following: Exposing, Scanning, Erasing, Changing Mode, Aborting, Error, and Waiting. |
It is useful to use NDPluginROI to define an ROI containing the entire mar345 detector. The MaxValue_RBV PV in this ROI can be monitored to make sure that the 16-bit limit of 65,535 is not being approached in any pixel.
The mar345 driver implements the following parameters in addition to those in ADStdDriverParams.h.
Note that to reduce the width of this table the enum names have been split into
2 lines, but these are just a single name, for example mar345ScanSize.
| Parameter Definitions in mar345.cpp and EPICS Record Definitions in mar345.template | ||||||
| Enum name | asyn interface | Access | Description | drvUser string | EPICS record name | EPICS record type |
|---|---|---|---|---|---|---|
| Readout parameters | ||||||
|
mar345 ScanSize |
asynInt32 | r/w | The detector diameter to read out. Choices are 180mm, 240mm, 300mm, and 345mm. | MAR_SIZE |
$(P)$(R)ScanSize $(P)$(R)ScanSize_RBV |
mbbo mbbi |
|
mar345 ScanResolution |
asynInt32 | r/w | The pixel size to use when reading the detector out. Choices are 0.10 and 0.15mm. | MAR_RESOLUTION |
$(P)$(R)ScanResolution $(P)$(R)ScanResolution_RBV |
mbbo mbbi |
|
mar345 ChangeMode |
asynInt32 | r/w | Writing 1 to this parameter causes the ScanSize and ScanResolution values to be sent to the server, changing the scan mode. This is not strictly necessary, because the size and resolution is also encoded in the file extension used in the scan command. However, changing the mode before doing a scan reduces the time for the scan, because the detector is already configured for the correct mode. | MAR_CHANGE_MODE |
$(P)$(R)ChangeMode $(P)$(R)ChangedMode_RBV |
busy bi |
| Erase parameters | ||||||
|
mar345 EraseMode |
asynInt32 | r/w | Controls whether an erase cycle should be automatically performed during acquisition. Choices are None, Before expose, and After scan. | MAR_ERASE_MODE |
$(P)$(R)EraseMode $(P)$(R)EraseMode_RBV |
mbbo mbbi |
|
mar345 NumErase |
asynInt32 | r/w | The number of erase cycles to perform each time the detector is erased, either because the mar345Erase parameter is set to 1, or because of an automatic erase as part of an acquisition. | MAR_NUM_ERASE |
$(P)$(R)NumErase $(P)$(R)NumErase_RBV |
longout longin |
|
mar345 Erase |
asynInt32 | r/w | Write 1 to this parameter to initiate erasing the detector. The detector will be erased multiple times if mar345NumErase is greater than 1. | MAR_ERASE |
$(P)$(R)Erase $(P)$(R)Erase_RBV |
busy bi |
| Abort parameters | ||||||
|
mar345 Abort |
asynInt32 | r/w | Writing 1 to this parameter aborts the current operation as soon as possible and returns the driver to the idle state. Note however that commands to the mar345 server cannot be aborted, so the driver must wait for the current command to complete. | MAR_ABORT |
$(P)$(R)Abort $(P)$(R)Abort_RBV |
bo bi |
| Debugging | ||||||
| N/A | N/A | N/A | asyn record to control debugging communication with mar345dtb program | N/A | $(P)$(R)marSserverAsyn | asyn |
The mar345 driver does not support the following standard driver parameters because they are not supported in the mar345dtb program:
The mar345 driver is created with the following command, either from C/C++ or from the EPICS IOC shell.
mar345Config(const char *portName, const char *mar345Port,
int maxBuffers, size_t maxMemory);
| Argument | Description |
|---|---|
portName |
The name of the asyn port for this detector. |
mar345Port |
The name of the asyn TCP/IP port to communicate with mar345dtb. This
must have been previously created with drvAsynIPPortConfig(),
|
maxBuffers |
Maximum number of buffers to be created for plugin callbacks. Passed to the constructor for the ADDriver base class. |
maxMemory |
Maximum number of bytes of memory to be allocated for plugin callbacks. Passed to the constructor for the ADDriver base class. |
The following is an example st.cmd startup script:
<envPaths
errlogInit(20000)
dbLoadDatabase("$(AREA_DETECTOR)/dbd/mar345App.dbd")
mar345App_registerRecordDeviceDriver(pdbbase)
###
# Create the asyn port to talk to the MAR on port 5001
drvAsynIPPortConfigure("marServer","gse-marip2.cars.aps.anl.gov:5001")
# Set the input and output terminators.
asynOctetSetInputEos("marServer", 0, "\n")
asynOctetSetOutputEos("marServer", 0, "\n")
asynSetTraceIOMask("marServer",0,2)
#asynSetTraceMask("marServer",0,255)
mar345Config("MAR", "marServer", 20, 200000000)
asynSetTraceIOMask("MAR",0,2)
#asynSetTraceMask("MAR",0,255)
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/ADBase.template", "P=13MAR345_1:,R=cam1:,PORT=MAR,ADDR=0,TIMEOUT=1")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDFile.template","P=13MAR345_1:,R=cam1:,PORT=MAR,ADDR=0,TIMEOUT=1")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/mar345.template","P=13MAR345_1:,R=cam1:,PORT=MAR,ADDR=0,TIMEOUT=1,MARSERVER_PORT=marServer")
# Create a standard arrays plugin
drvNDStdArraysConfigure("MARImage", 5, 0, "MAR", 0, -1)
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDPluginBase.template","P=13MAR345_1:,R=image1:,PORT=MARImage,ADDR=0,TIMEOUT=1,NDARRAY_PORT=MAR,NDARRAY_ADDR=0")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDStdArrays.template", "P=13MAR345_1:,R=image1:,PORT=MARImage,ADDR=0,TIMEOUT=1,SIZE=16,FTVL=SHORT,NELEMENTS=12000000")
# Create an ROI plugin
drvNDROIConfigure("MARROI", 5, 0, "MAR", 0, 4, 20, -1)
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDPluginBase.template","P=13MAR345_1:,R=ROI1:, PORT=MARROI,ADDR=0,TIMEOUT=1,NDARRAY_PORT=MAR,NDARRAY_ADDR=0")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDROI.template", "P=13MAR345_1:,R=ROI1:, PORT=MARROI,ADDR=0,TIMEOUT=1")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDROIN.template", "P=13MAR345_1:,R=ROI1:0:,PORT=MARROI,ADDR=0,TIMEOUT=1,HIST_SIZE=256")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDROIN.template", "P=13MAR345_1:,R=ROI1:1:,PORT=MARROI,ADDR=1,TIMEOUT=1,HIST_SIZE=256")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDROIN.template", "P=13MAR345_1:,R=ROI1:2:,PORT=MARROI,ADDR=2,TIMEOUT=1,HIST_SIZE=256")
dbLoadRecords("$(AREA_DETECTOR)/ADApp/Db/NDROIN.template", "P=13MAR345_1:,R=ROI1:3:,PORT=MARROI,ADDR=3,TIMEOUT=1,HIST_SIZE=256")
#asynSetTraceMask("MARROI",0,3)
#asynSetTraceIOMask("MARROI",0,4)
# Load scan records
dbLoadRecords("$(SSCAN)/sscanApp/Db/scan.db", "P=13MAR345_1:,MAXPTS1=2000,MAXPTS2=200,MAXPTS3=20,MAXPTS4=10,MAXPTSH=10")
set_requestfile_path("./")
set_savefile_path("./autosave")
set_requestfile_path("$(AREA_DETECTOR)/ADApp/Db")
set_requestfile_path("$(SSCAN)/sscanApp/Db")
set_pass0_restoreFile("auto_settings.sav")
set_pass1_restoreFile("auto_settings.sav")
save_restoreSet_status_prefix("13MAR345_1:")
dbLoadRecords("$(AUTOSAVE)/asApp/Db/save_restoreStatus.db", "P=13MAR345_1:")
iocInit()
# save things every thirty seconds
create_monitor_set("auto_settings.req", 30,"P=13MAR345_1:,D=cam1:")
The following show the MEDM screens that are used to control the mar345 detector. Note that the general purpose screen ADBase.adl can be used, but it exposes many controls that are not applicable to the mar345, and lacks some fields that are important for the Mmar345.
mar345.adl is the main screen used to control the mar345 driver.

The mar345 is definitely not a fast detector! The following measurements show the time to perform various erase and scan operations. Note that because the mar345 file format is compressed the file sizes are typically much less than the image sizes listed.
| Scan diameter | Pixel size | Image dimensions | Image size (MB) | Time to scan | Time to erase |
|---|---|---|---|---|---|
| 180 mm | 0.15 mm | 1200x1200 | 2.7 | 38.6 | 37.8 |
| 240 mm | 0.15 mm | 1600x1600 | 4.9 | 50.4 | 50.8 |
| 300 mm | 0.15 mm | 2000x2000 | 7.6 | 74.7 | 66.9 |
| 345 mm | 0.15 mm | 2300x2300 | 10.1 | 88.6 | 82.7 |
| 180 mm | 0.10 mm | 1800x1800 | 6.2 | 46.4 | 45.9 |
| 240 mm | 0.10 mm | 2400x2400 | 11.0 | 71.9 | 63.8 |
| 300 mm | 0.10 mm | 3000x3000 | 17.2 | 89.1 | 87.0 |
| 345 mm | 0.10 mm | 3450x3450 | 22.7 | 107.5 | 107.1 |
The following are some current restrictions of the mar345 driver: