mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
mythenDetectorServer now works with dacs_t and the commands vpreamp and vcalibration respond correctly
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@226 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -14,6 +14,7 @@ SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_func
|
||||
OBJS= $(SRCS:%.c=%.o)
|
||||
|
||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE
|
||||
#-DDACS_INT
|
||||
#-DVERYVERBOSE
|
||||
#-Werror
|
||||
|
||||
|
@ -38,8 +38,8 @@ const int noneSelected=-1;
|
||||
sls_detector_module *detectorModules=NULL;
|
||||
int *detectorChips=NULL;
|
||||
int *detectorChans=NULL;
|
||||
float *detectorDacs=NULL;
|
||||
float *detectorAdcs=NULL;
|
||||
dacs_t *detectorDacs=NULL;
|
||||
dacs_t *detectorAdcs=NULL;
|
||||
//int numberOfProbes;
|
||||
|
||||
|
||||
@ -61,8 +61,8 @@ int initDetector() {
|
||||
detectorChips=malloc(n*NCHIP*sizeof(int));
|
||||
|
||||
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(float));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(float));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(dacs_t));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(dacs_t));
|
||||
#ifdef VERBOSE
|
||||
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
|
||||
printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP);
|
||||
@ -440,6 +440,9 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
// sls_detector_module *myMod;
|
||||
control=9+addr;
|
||||
|
||||
int ireg;
|
||||
|
||||
|
||||
|
||||
printf("programming dac %d value %d module %d\n",addr, value,imod);
|
||||
#ifdef MAX5533
|
||||
@ -474,12 +477,16 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
#endif
|
||||
idac=sDac*2+addr;
|
||||
|
||||
|
||||
ireg=idac;
|
||||
|
||||
if (idac==VCAL) {
|
||||
idac=RGPR;
|
||||
} else if (idac==RGPR){
|
||||
idac=VCAL;
|
||||
}
|
||||
|
||||
|
||||
if (detectorDacs) {
|
||||
sMod=imod;
|
||||
if (imod==ALLMOD)
|
||||
@ -488,13 +495,13 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
if (imod>=0 && imod<nModX) {
|
||||
// myMod=detectorModules+imod;
|
||||
//(detectorModules+imod)->dacs[idac]=v;
|
||||
detectorDacs[idac+NDAC*imod]=v;
|
||||
detectorDacs[ireg+NDAC*imod]=v;
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod);
|
||||
#endif
|
||||
|
||||
setDACRegister(idac,v,imod);
|
||||
setDACRegister(ireg,v,imod);
|
||||
|
||||
/*
|
||||
|
||||
@ -542,7 +549,7 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
//#endif
|
||||
} else if (imod==ALLMOD) {
|
||||
for (im=0; im<nModX; im++) {
|
||||
detectorDacs[idac+NDAC*im]=v;
|
||||
detectorDacs[ireg+NDAC*im]=v;
|
||||
|
||||
/*
|
||||
#ifdef VERBOSE
|
||||
@ -592,7 +599,7 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
printf("after setting dac %d module %d -- %x -- %x addr %d\n",idac, im, reg, bus_r(MOD_DACS2_REG+(im<<SHIFTMOD)));
|
||||
#endif
|
||||
*/
|
||||
setDACRegister(idac,v,im);
|
||||
setDACRegister(ireg,v,im);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -640,12 +647,19 @@ int set_one_dac(int imod) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
float initDACbyIndex(int ind,float val, int imod) {
|
||||
dacs_t initDACbyIndex(int ind,dacs_t ival, int imod) {
|
||||
int v;
|
||||
const float partref[NDAC]=PARTREF;
|
||||
const float partr1[NDAC]=PARTR1;
|
||||
const float partr2[NDAC]=PARTR2;
|
||||
|
||||
float val;
|
||||
#ifdef DACS_INT
|
||||
val=((float)ival)*1E-3;
|
||||
#else
|
||||
val=ival;
|
||||
#endif
|
||||
|
||||
float ref=partref[ind];
|
||||
float r1=partr1[ind];
|
||||
float r2=partr2[ind];
|
||||
@ -657,10 +671,10 @@ float initDACbyIndex(int ind,float val, int imod) {
|
||||
return (v*DAC_MAX/DAC_DR+ref*r1/r2)/(1+r1/r2);
|
||||
}
|
||||
|
||||
float initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
dacs_t initDACbyIndexDACU(int ind, dacs_t val, int imod) {
|
||||
|
||||
const float daccs[NDAC]=DACCS;
|
||||
const float dacaddr[NDAC]=DACADDR;
|
||||
const int daccs[NDAC]=DACCS;
|
||||
const int dacaddr[NDAC]=DACADDR;
|
||||
|
||||
int cs=daccs[ind];
|
||||
int addr=dacaddr[ind];
|
||||
@ -820,7 +834,7 @@ int setThresholdEnergy(int ethr) {
|
||||
|
||||
|
||||
|
||||
float getDACbyIndexDACU(int ind, int imod) {
|
||||
dacs_t getDACbyIndexDACU(int ind, int imod) {
|
||||
/*
|
||||
if (detectorDacs) {
|
||||
if (imod<getNModBoard())
|
||||
@ -923,7 +937,7 @@ int setSettings(int i) {
|
||||
irgsh2=detectorDacs[imod*NDAC+RGSH2];
|
||||
*/
|
||||
|
||||
irgpr=setDACRegister(4,-1,imod);
|
||||
irgpr=setDACRegister(RGPR,-1,imod);
|
||||
irgsh1=setDACRegister(RGSH1,-1,imod);
|
||||
irgsh2=setDACRegister(RGSH2,-1,imod);
|
||||
for (is=STANDARD; is<UNDEFINED; is++) {
|
||||
@ -936,7 +950,7 @@ int setSettings(int i) {
|
||||
#endif
|
||||
for (imod=1; imod<nModX; imod++) {
|
||||
if (isett!=UNDEFINED) {
|
||||
irgpr=setDACRegister(4,-1,imod);
|
||||
irgpr=setDACRegister(RGPR,-1,imod);
|
||||
irgsh1=setDACRegister(RGSH1,-1,imod);
|
||||
irgsh2=setDACRegister(RGSH2,-1,imod);
|
||||
/*
|
||||
|
@ -100,9 +100,9 @@ int set_one_dac(int imod);
|
||||
int initDAC(int dac_cs, int dac_addr, int value,int imod );
|
||||
int initDACs(int* v,int imod );
|
||||
int setSettings(int i);
|
||||
float initDACbyIndex(int ind,float val, int imod);
|
||||
float initDACbyIndexDACU(int ind,int val, int imod);
|
||||
float getDACbyIndexDACU(int ind, int imod);
|
||||
dacs_t initDACbyIndex(int ind,dacs_t val, int imod);
|
||||
dacs_t initDACbyIndexDACU(int ind,dacs_t val, int imod);
|
||||
dacs_t getDACbyIndexDACU(int ind, int imod);
|
||||
int getThresholdEnergy();
|
||||
int setThresholdEnergy(int ethr);
|
||||
/* Initialization*/
|
||||
|
@ -842,13 +842,13 @@ int read_register(int file_des) {
|
||||
|
||||
int set_dac(int file_des) {
|
||||
|
||||
float retval;
|
||||
dacs_t retval;
|
||||
int ret=OK;
|
||||
int arg[2];
|
||||
enum dacIndex ind;
|
||||
int imod;
|
||||
int n;
|
||||
float val;
|
||||
dacs_t val;
|
||||
int idac=0;
|
||||
|
||||
sprintf(mess,"Can't set DAC\n");
|
||||
@ -954,7 +954,7 @@ add possible potentiometers like in chiptest board!!!!!!!!!!!!!!!
|
||||
|
||||
int get_adc(int file_des) {
|
||||
|
||||
float retval;
|
||||
dacs_t retval;
|
||||
int ret=OK;
|
||||
int arg[2];
|
||||
enum dacIndex ind;
|
||||
@ -1309,11 +1309,15 @@ int get_chip(int file_des) {
|
||||
|
||||
}
|
||||
int set_module(int file_des) {
|
||||
|
||||
|
||||
sls_detector_module myModule;
|
||||
int *myChip=malloc(NCHIP*sizeof(int));
|
||||
int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
float *myDac=malloc(NDAC*sizeof(int));
|
||||
float *myAdc=malloc(NADC*sizeof(int));
|
||||
|
||||
dacs_t *myDac=malloc(NDAC*sizeof(dacs_t));
|
||||
dacs_t *myAdc=malloc(NADC*sizeof(dacs_t));
|
||||
|
||||
int retval, n;
|
||||
int ret=OK;
|
||||
int dr;//, ow;
|
||||
@ -1431,8 +1435,8 @@ int get_module(int file_des) {
|
||||
sls_detector_module myModule;
|
||||
int *myChip=malloc(NCHIP*sizeof(int));
|
||||
int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
float *myDac=malloc(NDAC*sizeof(int));
|
||||
float *myAdc=malloc(NADC*sizeof(int));
|
||||
dacs_t *myDac=malloc(NDAC*sizeof(dacs_t));
|
||||
dacs_t *myAdc=malloc(NADC*sizeof(dacs_t));
|
||||
|
||||
|
||||
if (myDac)
|
||||
|
Reference in New Issue
Block a user