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