Cyclotron Laboratory, Institute of Physical and Chemical Research (RIKEN)
24 Dec. 1997
software
The data acquisition system was designed for that several analysis processes
(analyzer) can be executed at same time.
Undesirable destroy of control process or X-window system does not
affect on the system.
Linux is not complete real-time operating system.
Therefore, in this system,
acquisition process is included inside of the operating system
as an device driver for speed up.
A look-at-me signal from CAMAC modules makes activates interrupt routine
(dc_int.c) via interrupt request signal (IRQ) on the PCI interface board.
In the interrupt routine, you should describe what kind of data you
want to measure and structure of event buffer (short int buffer[]).
The event data are copied the 64 kwords buffer inside of the device
driver which is read by a blocking process (dma_control).
The blocking process gathers events to 16 kbyte blocks in the shared
memory as well as stores a file in hard disk with the blocks when you need.
The blocks in the shared memory can be read from other processes,
for example, analyzing, status-report processes.
The device driver and the blocking process are controlled by a control
process (COM) via I/O-control functions to the device driver.
Here is an example.
#include "camack.c" #define INPUT_REGISTER 1 /* station number of input register */ #define INPUT_REG_RF 0 /* read function of input register */ #define INPUT_REG_RA 0 /* read sub-address of input register */ #define INPUT_REG_CF 9 /* clear function of input register */ #define INPUT_REG_CA 0 /* clear sub-address of input register */ #define ADC 2 /* station number of ADC */ #define ADC_RF 0 /* read function of ADC */ #define ADC_CF 9 /* clear function of ADC */ #define ADC_CA 0 /* clear sub-address of ADC */ #define SCALER 4 /* station number of scaler */ #define SCALER_RF 0 /* read function for scaler */ #define SCALER_CF 9 /* clear function for scaler */ #define SCALER_CA 0 /* clear sub-address for scaler */ #define OUTPUT_REGISTER 5 /* station number of output register */ #define OUTPUT_REG_F 17 /* write function of output register */ #define OUTPUT_REG_A 0 /* write sub-address of output register*/ #define LAM_N ADC /* LAM source is ADC */ #define LAM_F 26 /* function for enable-LAM */ #define LAM_A 0 /* sub-address for enable-LAM */ static long loop=0,data; static int stat; static void dc_int_init(),dc_int_start(),dc_int_stop(),dc_int_clear(); static void dc_int_init() { camac_CNAF(0,SCALER,SCALER_CA,SCALER_CF); /* clear scaler */ } static void dc_int_start() { camac_write24(0x0000f0); camac_CNAF(0,OUTPUT_REGISTER,OUTPUT_REG_A,OUTPUT_REG_F); /* send signal to output register A=5-8 */ dc_int_clear(); /* clear LAM and modules */ camac_CNAF(0,LAM_N,LAM_A,LAM_F); /* enable LAM */ } static void dc_int_stop() { camac_CNAF(0,LAM_N,LAM_A,24); /* disable LAM */ camac_write24(0x000f00); camac_CNAF(0,OUTPUT_REGISTER,OUTPUT_REG_A,OUTPUT_REG_F); /* send signal to output register A=9-12 */ } static void dc_int_clear() { camac_CNAF(0,ADC,ADC_CA,ADC_CF); /* clear data of ADC */ camac_CNAF(0,ADC,ADC_CA,10); /* clear LAM of ADC */ camac_CNAF(0,INPUT_REGISTER,INPUT_REG_CA,INPUT_REG_CF); /* clear input register */ camac_write24(0x00000f); camac_CNAF(0,OUTPUT_REGISTER,OUTPUT_REG_A,OUTPUT_REG_F); /* send signal to output register A=1-4 */ } static int dc_int(unsigned short buffer[]) { long j; loop++; j=inl(BASE_ADDRESS+4); /* check LAM */ if(j==0){ printk("dc_int: interrupt %d happened, %d, LAM=%lx\n",IRQ,loop,j); /* write warning for illegal LAM to dmesg */ return(-1); /* return */ } buffer[0]=8; /* fixed event length (8 words) */ camac_CNAF(0,INPUT_REGISTER,INPUT_REG_RA,INPUT_REG_RF); buffer[1]=camac_read16(); /* first data is bit pattern of input register*/ camac_CNAF(0,ADC,0,ADC_RF); buffer[2]=camac_read16(); /* second data is ADC A=0 */ camac_CNAF(0,ADC,1,ADC_RF); buffer[3]=camac_read16(); /* the third data is ADC A=1 */ camac_CNAF(0,ADC,2,ADC_RF); buffer[4]=camac_read16(); /* the fourth data is ADC A=2 */ camac_CNAF(0,ADC,3,ADC_RF); buffer[5]=camac_read16(); /* the fifth data is ADC A=3 */ camac_CNAF(0,SCALER,0,SCALER_RF); j=camac_read24(); buffer[6]=j&0xffff; buffer[7]=(j>>16)&0xffff; /* 24 bit write for scaler */ return(0); }
Here is an example
#include "/cern/97a/include/cfortran/cfortran.h" #include "/cern/97a/include/cfortran/hbook.h" /* these include files are need for calling HBOOK subroutines from the C language */ #define HBOOK_SIZE 200000 void analyze_(unsigned short int data[]) { static int loop=0; int i,j; if(loop==0){ HLIMAP(HBOOK_SIZE,"SAMPLE"); /* make global section "SAMPLE"*/ HBOOK1(11,"SSD1R-L",4095,0.5,4095.5,0.0);/* define 1-dim histograms */ HBOOK1(12,"SSD2R-L",4095,0.5,4095.5,0.0);/* see HBOOK manuals in CERN-lib*/ HBOOK1(13,"SSD3R-L",4095,0.5,4095.5,0.0); HBOOK1(14,"SSD4R-L",4095,0.5,4095.5,0.0); HBOOK1(15,"SSD5R-L",4095,0.5,4095.5,0.0); HBOOK1(16,"SSD6R-L",4095,0.5,4095.5,0.0); HBOOK1(17,"SSD7R-L",4095,0.5,4095.5,0.0); HBOOK1(18,"SSD8R-L",4095,0.5,4095.5,0.0); HBOOK1(19,"SSDR-L",4095,0.5,4095.5,0.0); HBOOK1(21,"SSD1L-L",4095,0.5,4095.5,0.0); HBOOK1(22,"SSD2L-L",4095,0.5,4095.5,0.0); HBOOK1(23,"SSD3L-L",4095,0.5,4095.5,0.0); HBOOK1(24,"SSD4L-L",4095,0.5,4095.5,0.0); HBOOK1(25,"SSD5L-L",4095,0.5,4095.5,0.0); HBOOK1(26,"SSD6L-L",4095,0.5,4095.5,0.0); HBOOK1(27,"SSD7L-L",4095,0.5,4095.5,0.0); HBOOK1(28,"SSD8L-L",4095,0.5,4095.5,0.0); HBOOK1(29,"SSDL-L",4095,0.5,4095.5,0.0); HBOOK1(31,"SSD1R-H",4095,0.5,4095.5,0.0); HBOOK1(32,"SSD2R-H",4095,0.5,4095.5,0.0); HBOOK1(33,"SSD3R-H",4095,0.5,4095.5,0.0); HBOOK1(34,"SSD4R-H",4095,0.5,4095.5,0.0); HBOOK1(35,"SSD5R-H",4095,0.5,4095.5,0.0); HBOOK1(36,"SSD6R-H",4095,0.5,4095.5,0.0); HBOOK1(37,"SSD7R-H",4095,0.5,4095.5,0.0); HBOOK1(38,"SSD8R-H",4095,0.5,4095.5,0.0); HBOOK1(39,"SSDR-H",4095,0.5,4095.5,0.0); HBOOK1(41,"SSD1L-H",4095,0.5,4095.5,0.0); HBOOK1(42,"SSD2L-H",4095,0.5,4095.5,0.0); HBOOK1(43,"SSD3L-H",4095,0.5,4095.5,0.0); HBOOK1(44,"SSD4L-H",4095,0.5,4095.5,0.0); HBOOK1(45,"SSD5L-H",4095,0.5,4095.5,0.0); HBOOK1(46,"SSD6L-H",4095,0.5,4095.5,0.0); HBOOK1(47,"SSD7L-H",4095,0.5,4095.5,0.0); HBOOK1(48,"SSD8L-H",4095,0.5,4095.5,0.0); HBOOK1(49,"SSDL-H",4095,0.5,4095.5,0.0); } loop++; i=data[1]&0x07; /* the event data are stored in data */ HF1(11+i,(float)data[2],1.0); /* fill histograms */ HF1(19,(float)data[2],1.0); HF1(31+i,(float)data[3],1.0); HF1(39,(float)data[3],1.0); i=(data[1]>>3)&0x07; HF1(21+i,(float)data[4],1.0); HF1(29,(float)data[4],1.0); HF1(41+i,(float)data[5],1.0); HF1(49,(float)data[5],1.0); }
address | BASE ADDRESS+0 | BASE ADDRESS+4 | BASE ADDRESS+8 | |||
---|---|---|---|---|---|---|
BIT | write | read | write | read | write | read |
31 | - | - | - | - | - | - |
30 | - | - | - | - | - | - |
29 | - | - | - | - | - | - |
28 | - | - | - | - | - | - |
27 | - | - | - | - | - | - |
26 | - | - | - | - | - | - |
25 | - | - | - | - | - | - |
24 | - | - | - | - | - | - |
23 | - | - | - | LAM station 24 | data bit 24 | data bit 24 |
22 | - | - | - | LAM station 23 | data bit 23 | data bit 23 |
21 | - | - | - | LAM station 22 | data bit 22 | data bit 22 |
20 | - | - | - | LAM station 21 | data bit 21 | data bit 21 |
19 | - | - | - | LAM station 20 | data bit 20 | data bit 20 |
18 | - | - | crate Address 04 | LAM station 19 | data bit 19 | data bit 19 |
17 | - | - | crate Address 02 | LAM station 18 | data bit 18 | data bit 18 |
16 | - | - | crate Address 01 | LAM station 17 | data bit 17 | data bit 17 |
15 | - | - | - | LAM station 16 | data bit 16 | data bit 16 |
14 | - | - | - | LAM station 15 | data bit 15 | data bit 15 |
13 | - | - | station number 16 | LAM station 14 | data bit 14 | data bit 14 |
12 | - | - | station number 08 | LAM station 13 | data bit 13 | data bit 13 |
11 | - | - | station number 04 | LAM station 12 | data bit 12 | data bit 12 |
10 | - | - | station number 02 | LAM station 11 | data bit 11 | data bit 11 |
9 | - | - | station number 01 | LAM station 10 | data bit 10 | data bit 10 |
8 | - | - | subaddress 08 | LAM station 9 | data bit 09 | data bit 09 |
7 | LAM internal | LAM internal | subaddress 04 | LAM station 8 | data bit 08 | data bit 08 |
6 | reset | LAM sum | subaddress 02 | LAM station 7 | data bit 07 | data bit 07 |
5 | - | online | subaddress 01 | LAM station 6 | data bit 06 | data bit 06 |
4 | - | done | function 16 | LAM station 5 | data bit 05 | data bit 05 |
3 | enable interrupt | enable interrupt | function 08 | LAM station 4 | data bit 04 | data bit 04 |
2 | inhibit | inhibit | function 04 | LAM station 3 | data bit 03 | data bit 03 |
1 | initialize | no-X | function 02 | LAM station 2 | data bit 02 | data bit 02 |
0 | clear | no-Q | function 01 | LAM station 1 | data bit 01 | data bit 01 |