Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 89 → Rev 90

/sipmScan/src/sipmBias.c
34,7 → 34,7
# define NDAC 1 // CAEN C221
# define ASD8 0 // channels
# define AMPDISSH 1
# define SIPM 2
# define SIPM 15
# define CAEN_V673A 0x22220000 // IJS
//#define CAEN_V673A 0x10110000 // FMF
# define CAEN_V462 0x100300
41,13 → 41,13
#endif
 
#ifdef USE_MIKRO
# define MIKRO_COM 5
# define MIKRO_COM 3
# define MIKRO_X 1
# define USE_MIKRO_Y
# define MIKRO_Y 2
# define USE_MIKRO_Z
# define MIKRO_Z 3
# define STEP_TOLERANCE 50
# define STEP_TOLERANCE 1
#endif
 
#define MAXCH 512
57,6 → 57,8
 
#define NCH 64
#define POWERSUPPLY 66 // Power supply voltage for SiPM bias
#define OFFSETX 5600 // position of the lower right corner
#define OFFSETY 5200
 
static int p1h, pID, rID, tfID;
static int ph_tdc, ph_adc;
283,6 → 285,7
 
//if (dsave) {
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
SetCtrlVal(p1h, P1_FCOUNT, fcount);
fp = fopen (dfile, "wb");
time (&runrec.time);
301,6 → 304,7
SetCtrlVal(p1h, P1_SBIAS, biasrec.bias/1000.0);
status = fwrite(&biasrec, 1, biasrec.len, fp);
if (print) printf("BIASREC status %d len %d bias %d\n", status, biasrec.len, biasrec.bias);
wait_loop(10000);
// Set ASD threshold voltage
thrrec.threshold = (unsigned long) ceil(thresholdLow*1000); // threshold in mV
309,6 → 313,7
SetCtrlVal(p1h, P1_SASD8THR, thrrec.threshold/1000.0);
status = fwrite(&thrrec, 1, thrrec.len, fp);
if (print) printf("THRREC status %d len %d threshold %d\n", status, thrrec.len, thrrec.threshold);
wait_loop(10000);
for (posrec.ix=0; posrec.ix<runrec.nx; posrec.ix++) {
posrec.xset = runrec.x0 + posrec.ix*runrec.dx;
315,8 → 320,9
#ifdef USE_MIKRO
//printf("MIKRO_MoveTo (1, x);%d\n",posrec.x);
do {
MIKRO_MoveTo (MIKRO_X, posrec.xset);
MIKRO_MoveTo (MIKRO_X, OFFSETX + posrec.xset);
MIKRO_GetPosition(MIKRO_X, &mikroX);
mikroX -= OFFSETX;
} while (abs(posrec.xset - mikroX) > STEP_TOLERANCE);
//printf("->MIKRO_MoveTo (1, x);%d\n",posrec.xset);
#endif
329,8 → 335,9
#ifdef USE_MIKRO_Y
//printf("MIKRO_MoveTo (2, y);%d\n",y);
do {
MIKRO_MoveTo (MIKRO_Y, posrec.yset);
MIKRO_MoveTo (MIKRO_Y, OFFSETY + posrec.yset);
MIKRO_GetPosition(MIKRO_Y, &mikroY);
mikroY -= OFFSETY;
} while (abs(posrec.yset - mikroY) > STEP_TOLERANCE);
//printf("->MIKRO_MoveTo (2, y);%d\n",posrec.yset);
#endif
465,6 → 472,7
status = fwrite (&endrec, 1, endrec.len, fp);
fcount+=1;
sprintf(dfile,"%s_file%02d.dat",dfile0,fcount);
SetCtrlVal(p1h, P1_FCOUNT, fcount);
fclose(fp);
fp = fopen (dfile, "wb");
}
491,9 → 499,11
} // y loop
if (!daq_on) break;
thrrec.threshold += thresholdStep*1000;
wait_loop(10000);
} // threhsold loop
if (!daq_on) break;
biasrec.bias += runrec.biasStep;
wait_loop(10000);
} // bias loop
SetDac(SIPM, 0); // safety
539,7 → 549,8
{
int i,j,status,refon;
long int xpos, ypos, zpos;
char dfile[300];
char dfile[256];
char message[128];
FILE *fp;
typedef struct {
579,6 → 590,11
DisplayPanel (p1h);
SetCtrlAttribute (p1h, P1_PLCH, ATTR_MAX_VALUE, NCH-1);
sprintf(message, "%d", OFFSETX);
SetCtrlVal (p1h, P1_OFFSETX, message);
sprintf(message, "%d", OFFSETY);
SetCtrlVal (p1h, P1_OFFSETY, message);
GetCtrlVal(p1h, P1_ADCHLSAVE, &runrec.xy);
SetCtrlVal(p1h, P1_ADCHL, runrec.xy-2);