mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
Forst version to the users - still trimming problem
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@11 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
057d518ddc
commit
aeade907d0
@ -13,7 +13,8 @@ INSTMODE= 0777
|
||||
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
OBJS= $(SRCS:%.c=%.o)
|
||||
|
||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE
|
||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS
|
||||
#-DVERBOSE
|
||||
# -DVERYVERBOSE
|
||||
#-Werror
|
||||
|
||||
|
@ -834,24 +834,33 @@ int getDynamicRange() {
|
||||
}
|
||||
|
||||
int testBus() {
|
||||
int j;
|
||||
u_int32_t j, i;
|
||||
char cmd[100];
|
||||
u_int32_t val;
|
||||
printf("%s\n",cmd);
|
||||
system(cmd);
|
||||
for (j=0; j<1000000; j++) {
|
||||
val=bus_r(FIX_PATT_REG);
|
||||
if (val!=0xacdc1980){
|
||||
printf("%d %x\n",j, val);
|
||||
u_int32_t val=0x0;
|
||||
// printf("%s\n",cmd);
|
||||
// system(cmd);
|
||||
i=0;
|
||||
printf("testing bus\n");
|
||||
while (i<10000000) {
|
||||
// val=bus_r(FIX_PATT_REG);
|
||||
bus_w(DUMMY_REG,val);
|
||||
bus_w(FIX_PATT_REG,0x0);
|
||||
j=bus_r(DUMMY_REG);
|
||||
if (i%10000==1)
|
||||
printf("value 0x%x\n",j);
|
||||
if (j!=val){
|
||||
printf("read wrong value %x instead of %x\n",j, val);
|
||||
return FAIL;
|
||||
}
|
||||
val+=0xbbbbb;
|
||||
i++;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int setStoreInRAM(int b) {
|
||||
if (b)
|
||||
if (b>0)
|
||||
storeInRAM=1;
|
||||
else
|
||||
storeInRAM=0;
|
||||
|
@ -420,7 +420,10 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
int idac;
|
||||
int v=value;
|
||||
// sls_detector_module *myMod;
|
||||
control=9+addr;
|
||||
control=9+addr;
|
||||
|
||||
|
||||
printf("programming dac %d value %d module %d\n",addr, value,imod);
|
||||
#ifdef MAX5533
|
||||
value=value | (control<< 12);
|
||||
#endif
|
||||
@ -467,16 +470,16 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
if (imod>=0 && imod<getNModBoard()) {
|
||||
// myMod=detectorModules+imod;
|
||||
//(detectorModules+imod)->dacs[idac]=v;
|
||||
#ifdef VERBOSE
|
||||
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod);
|
||||
#endif
|
||||
detectorDacs[idac+NDAC*imod]=v;
|
||||
//#ifdef VERBOSE
|
||||
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod);
|
||||
//#endif
|
||||
} else if (imod==ALLMOD) {
|
||||
for (im=0; im<getNModBoard(); im++) {
|
||||
#ifdef VERBOSE
|
||||
printf("all: module=%d index=%d, val=%d addr=%x\n",im, idac, v,detectorDacs+idac+NDAC*im);
|
||||
#endif
|
||||
detectorDacs[idac+NDAC*im]=v;
|
||||
//#ifdef VERBOSE
|
||||
printf("all: module=%d index=%d, val=%d addr=%x\n",im, idac, v,detectorDacs+idac+NDAC*im);
|
||||
//#endif
|
||||
// (detectorModules+im)->dacs[idac]=v;
|
||||
}
|
||||
}
|
||||
@ -537,9 +540,9 @@ float initDACbyIndex(int ind,float val, int imod) {
|
||||
|
||||
|
||||
v=(val+(val-ref)*r1/r2)*DAC_DR/DAC_MAX;
|
||||
initDACbyIndexDACU(ind,v,imod);
|
||||
|
||||
return val;
|
||||
v=initDACbyIndexDACU(ind,v,imod);
|
||||
|
||||
return (v*DAC_MAX/DAC_DR+ref*r1/r2)/(1+r1/r2);
|
||||
}
|
||||
|
||||
float initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
@ -550,15 +553,27 @@ float initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
int cs=daccs[ind];
|
||||
int addr=dacaddr[ind];
|
||||
int iv;
|
||||
int im;
|
||||
|
||||
|
||||
initDAC(cs, addr,val, imod);
|
||||
if (val>=0) {
|
||||
initDAC(cs, addr,val, imod);
|
||||
/*#ifdef VERBOSE
|
||||
iv=detectorDacs[ind+imod*NDAC];
|
||||
printf("module=%d index=%d, cs=%d, addr=%d, dacu=%d, set to %d",imod, ind,cs,addr,val,iv);
|
||||
#endif
|
||||
*/
|
||||
return val;
|
||||
//return val;
|
||||
}
|
||||
if (imod>=0 && imod<nModX)
|
||||
return detectorDacs[ind+imod*NDAC];
|
||||
else {
|
||||
//iv=detectorDacs[ind];
|
||||
for (im=1; im<nModX; im++) {
|
||||
if (detectorDacs[ind+im*NDAC]!=detectorDacs[ind])
|
||||
return -1;
|
||||
}
|
||||
return detectorDacs[ind];
|
||||
}
|
||||
}
|
||||
|
||||
int getThresholdEnergy() {
|
||||
@ -659,9 +674,13 @@ int setThresholdEnergy(int ethr) {
|
||||
#ifdef VERBOSE
|
||||
printf("module %d (%x): gain %f, off %f, energy %d eV, dac %d\n",imod,(detectorModules+imod),(detectorModules+imod)->gain,(detectorModules+imod)->offset, ethr,dacu);
|
||||
#endif
|
||||
initDACbyIndexDACU(VTHRESH, dacu, imod);
|
||||
} else
|
||||
printf("could not set threshold energy for module %d, settings %d (offset is %f; gain is %f)\n",imod,myo,myg);
|
||||
} else {
|
||||
dacu=ethr;
|
||||
#ifdef VERBOSE
|
||||
printf("could not set threshold energy for module %d, settings %d (offset is %f; gain is %f)\n",imod,thisSettings,myo,myg);
|
||||
#endif
|
||||
}
|
||||
initDACbyIndexDACU(VTHRESH, dacu, imod);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -682,7 +701,7 @@ float getDACbyIndexDACU(int ind, int imod) {
|
||||
|
||||
int initDAC(int dac_cs, int dac_addr, int value, int imod) {
|
||||
int i;
|
||||
#ifdef DEBUGOUT
|
||||
#ifdef VERBOSE
|
||||
printf("Programming dac %d %d with value %d\n", dac_cs, dac_addr, value);
|
||||
#endif
|
||||
clearDACSregister(imod);
|
||||
@ -701,7 +720,6 @@ int initDAC(int dac_cs, int dac_addr, int value, int imod) {
|
||||
/*}*/
|
||||
set_one_dac(imod);
|
||||
nextDAC(imod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,9 @@ int main(int argc, char *argv[])
|
||||
b=0;
|
||||
printf("opening stop server on port %d\n",portno);
|
||||
}
|
||||
|
||||
#ifndef VIRTUAL
|
||||
system("bus -a 0xb0000000 -w 0xd0008");
|
||||
#endif
|
||||
init_detector(b);
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "server_funcs.h"
|
||||
#include "server_defs.h"
|
||||
@ -38,7 +37,9 @@ char mess[1000];
|
||||
|
||||
int init_detector( int b) {
|
||||
mapCSP0();
|
||||
#ifndef VIRTUAL
|
||||
system("bus -a 0xb0000000 -w 0xd0008");
|
||||
#endif
|
||||
testFpga();
|
||||
#ifdef MCB_FUNCS
|
||||
if (b) {
|
||||
@ -594,7 +595,7 @@ int digital_test(int fnum) {
|
||||
retval=testFpga();
|
||||
break;
|
||||
case DETECTOR_MEMORY_TEST:
|
||||
ret=FAIL;
|
||||
ret=testRAM();
|
||||
break;
|
||||
case DETECTOR_BUS_TEST:
|
||||
retval=testBus();
|
||||
@ -801,7 +802,7 @@ int set_dac(int fnum) {
|
||||
#ifdef VERBOSE
|
||||
printf("DAC set to %f V\n", retval);
|
||||
#endif
|
||||
if (retval==val)
|
||||
if (retval==val || val==-1)
|
||||
ret=OK;
|
||||
else {
|
||||
ret=FAIL;
|
||||
@ -1643,12 +1644,11 @@ int read_frame(int fnum) {
|
||||
if(getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2);
|
||||
#ifdef VERBOSE
|
||||
printf("%s\n",mess);
|
||||
#endif
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
sprintf(mess,"acquisition successfully finished\n");
|
||||
printf("%s\n",mess);
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
printf("%d %d %x %s\n",strlen(mess)+1,strlen(mess), mess,mess);
|
||||
@ -1681,9 +1681,11 @@ int read_frame(int fnum) {
|
||||
if (getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2);
|
||||
printf("%s\n",mess);
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
sprintf(mess,"acquisition successfully finished\n");
|
||||
printf("%s\n",mess);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Frames left %d\n",getFrames());
|
||||
@ -2084,6 +2086,8 @@ int set_readout_flags(int fnum) {
|
||||
//ret=setStoreInRAM(0);
|
||||
// initChipWithProbes(0,0,0, ALLMOD);
|
||||
switch(arg) {
|
||||
case GET_READOUT_FLAGS:
|
||||
break;
|
||||
case STORE_IN_RAM:
|
||||
ret=setStoreInRAM(1);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user