mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
settings fixed
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@107 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
3e8f916561
commit
918bcd3836
@ -278,7 +278,7 @@ int setPhaseShiftOnce(){
|
||||
bus_w(addr,(CHANGE_AT_POWER_ON_BIT|//DIGITAL_TEST_BIT|
|
||||
INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT&~PHASE_STEP_BIT));
|
||||
}
|
||||
|
||||
reg=bus_r(addr);
|
||||
#ifdef VERBOSE
|
||||
printf("Multipupose reg now:%d\n",reg);
|
||||
#endif
|
||||
@ -960,11 +960,12 @@ int setDACRegister(int idac, int val, int imod) {
|
||||
u_int32_t addr, reg, mask;
|
||||
int off;
|
||||
#ifdef VERBOSE
|
||||
printf("Settings dac %d module %d register to %d\n",idac,imod,val);
|
||||
if(val==-1)
|
||||
printf("Getting dac register%d module %d\n",idac,imod);
|
||||
else
|
||||
printf("Setting dac register %d module %d to %d\n",idac,imod,val);
|
||||
#endif
|
||||
|
||||
// addr=DUMMY_REG;
|
||||
//off=0;
|
||||
switch(idac){
|
||||
case 0:
|
||||
case 1:
|
||||
@ -1094,22 +1095,39 @@ int initHighVoltage(int val, int imod){
|
||||
|
||||
|
||||
|
||||
int initConfGain(int val, int imod){
|
||||
#ifdef VERBOSE
|
||||
printf("Setting/Getting confgain of module:%d with val:%d\n",imod,val);
|
||||
#endif
|
||||
int initConfGain(int isettings,int val,int imod){
|
||||
int retval;
|
||||
u_int32_t addr=GAIN_REG;
|
||||
|
||||
if(val!=-1){
|
||||
bus_w(addr,val);
|
||||
#ifdef VERBOSE
|
||||
printf("Value sent to confGain reg is %d\n",val);
|
||||
#endif
|
||||
printf("Setting Gain of module:%d with val:%d\n",imod,val);
|
||||
#endif
|
||||
bus_w(addr,((val<<GAIN_OFFSET)|(bus_r(addr)&~GAIN_MASK)));
|
||||
}
|
||||
val=bus_r(addr);
|
||||
retval=(bus_r(addr)&GAIN_MASK);
|
||||
#ifdef VERBOSE
|
||||
printf("Value read from confGain reg is %d\n",val);
|
||||
printf("Value read from Gain reg is %d\n",retval);
|
||||
#endif
|
||||
return val;
|
||||
if((val!=-1)&&(retval!=val))
|
||||
return -1;
|
||||
|
||||
if(isettings!=-1){
|
||||
#ifdef VERBOSE
|
||||
printf("Writing Settings of module:%d with val:%d\n",imod,isettings);
|
||||
#endif
|
||||
bus_w(addr,((isettings<<SETTINGS_OFFSET)|(bus_r(addr)&~SETTINGS_MASK)));
|
||||
}
|
||||
retval=((bus_r(addr)&SETTINGS_MASK)>>SETTINGS_OFFSET);
|
||||
#ifdef VERBOSE
|
||||
printf("Settings read from reg is %d\n",retval);
|
||||
#endif
|
||||
if((isettings!=-1)&&(retval!=isettings)){
|
||||
printf("\n\nSettings r\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,9 +51,9 @@ int setContinousReadOut(int d);
|
||||
|
||||
int setDACRegister(int idac, int val, int imod);
|
||||
|
||||
float getTemperature(int tempSensor, int imod);
|
||||
int initHighVoltage(int val, int imod);
|
||||
int initConfGain(int val, int imod);
|
||||
float getTemperature(int tempSensor,int imod);
|
||||
int initHighVoltage(int val,int imod);
|
||||
int initConfGain(int isettings,int val,int imod);
|
||||
|
||||
int configureMAC(int ipad, long long int macad, long long int servermacad, int ival);
|
||||
|
||||
|
@ -667,7 +667,7 @@ int setThresholdEnergy(int ethr) {
|
||||
int imod;
|
||||
int ret=ethr;
|
||||
|
||||
setSettings(GET_SETTINGS);
|
||||
setSettings(GET_SETTINGS,-1);//-1 added by dhanya
|
||||
if (thisSettings>=0 || thisSettings<3){
|
||||
myg=g[thisSettings];
|
||||
myo=o[thisSettings];
|
||||
@ -780,21 +780,20 @@ int initHighVoltageByModule(int val, int imod)
|
||||
}
|
||||
|
||||
|
||||
int initConfGainByModule(int val, int imod)
|
||||
int initConfGainByModule(int isettings,int val, int imod)
|
||||
{
|
||||
int im;
|
||||
//for the particular module
|
||||
if (imod>=0 && imod<nModX) {
|
||||
return initConfGain(val,imod);
|
||||
return initConfGain(isettings,val,imod);
|
||||
}
|
||||
else{
|
||||
//checks if all modules have the same value(ALLMOD)
|
||||
for (im=1; im<nModX; im++) {
|
||||
if (initConfGain(val,im)!=initConfGain(val,0)) {
|
||||
if (initConfGain(isettings,val,im)!=initConfGain(isettings,val,0))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return initConfGain(val,0);
|
||||
return initConfGain(isettings,val,0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -839,105 +838,42 @@ int initDACs(int* v,int imod)
|
||||
|
||||
|
||||
|
||||
int setSettings(int i)
|
||||
int setSettings(int i, int imod)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
printf("\ninside set settings wit settins=%d...\n",i);
|
||||
#endif
|
||||
int imod, isett, is;
|
||||
int vrefds[] = VREFDS_VALS;
|
||||
int vcascn[] = VCASCN_VALS;
|
||||
int vcascp[] = VCASCP_VALS;
|
||||
int voutcm[] = VOUTCM_VALS;
|
||||
int vcascout[] =VCASCOUT_VALS;
|
||||
int vincm[] = VINCM_VALS;
|
||||
int vrefcomp[] = VREFCOMP_VALS ;
|
||||
int ibtestc[] = IBTESTC_VALS;
|
||||
int confgain[] = CONF_GAIN;
|
||||
int isett=-2,retval;
|
||||
|
||||
int ivrefds,ivcascn,ivcascp,ivoutcm,ivcascout,ivincm,ivrefcomp,iibtestc;
|
||||
|
||||
int v[NDAC];
|
||||
int ind;
|
||||
for (ind=0; ind<NDAC; ind++)
|
||||
v[ind]=-1;
|
||||
|
||||
//for confGain Register
|
||||
if(thisSettings!=UNDEFINED)
|
||||
|
||||
//if not get settings
|
||||
if ((i>=HIGHGAIN) && (i<= VERYHIGHGAIN)) {
|
||||
v[VREF_DS]=vrefds[i];
|
||||
v[VCASCN_PB]=vcascn[i];
|
||||
v[VCASCP_PB]=vcascp[i];
|
||||
v[VOUT_CM]=voutcm[i];
|
||||
v[VCASC_OUT]=vcascout[i];
|
||||
v[VIN_CM]=vincm[i];
|
||||
v[VREF_COMP]=vrefcomp[i];
|
||||
v[IB_TESTC]=ibtestc[i];
|
||||
|
||||
initDACs(v,ALLMOD);
|
||||
thisSettings=i;
|
||||
//reading settings
|
||||
if(i==GET_SETTINGS){
|
||||
retval=initConfGainByModule(i,i,imod);
|
||||
if(retval==i)
|
||||
isett=UNDEFINED;
|
||||
}
|
||||
|
||||
//check settings for module 0
|
||||
imod=0;
|
||||
isett=UNDEFINED;
|
||||
ivrefds=setDACRegister(VREF_DS,-1,imod);
|
||||
ivcascn=setDACRegister(VCASCN_PB,-1,imod);
|
||||
ivcascp=setDACRegister(VCASCP_PB,-1,imod);
|
||||
ivoutcm=setDACRegister(VOUT_CM,-1,imod);
|
||||
ivcascout=setDACRegister(VCASC_OUT,-1,imod);
|
||||
ivincm=setDACRegister(VIN_CM,-1,imod);
|
||||
ivrefcomp=setDACRegister(VREF_COMP,-1,imod);
|
||||
iibtestc=setDACRegister(IB_TESTC,-1,imod);
|
||||
|
||||
for (is=HIGHGAIN; is<UNDEFINED; is++) {
|
||||
if (ivrefds==vrefds[is] && ivcascn==vcascn[is] && ivcascp==vcascp[is] &&
|
||||
ivoutcm==voutcm[is] && ivcascout==vcascout[is] && ivincm==vincm[is] &&
|
||||
ivrefcomp==vrefcomp[is] && iibtestc==ibtestc[is] ) {
|
||||
printf("ivref from dummyreg =%d\n",ivrefds);
|
||||
printf("vreg[%d] is %d\n",is,vrefds[is]);
|
||||
isett = is;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Settings of module 0 are %d\n",isett);
|
||||
#endif
|
||||
//writing settings
|
||||
else{
|
||||
retval=initConfGainByModule(i,confgain[i],imod);
|
||||
if(retval!=i)
|
||||
isett=UNDEFINED;
|
||||
}
|
||||
|
||||
for (imod=1; imod<nModX; imod++) {
|
||||
if (isett!=UNDEFINED) {
|
||||
ivrefds=setDACRegister(VREF_DS,-1,imod);
|
||||
ivcascn=setDACRegister(VCASCN_PB,-1,imod);
|
||||
ivcascp=setDACRegister(VCASCP_PB,-1,imod);
|
||||
ivoutcm=setDACRegister(VOUT_CM,-1,imod);
|
||||
ivcascout=setDACRegister(VCASC_OUT,-1,imod);
|
||||
ivincm=setDACRegister(VIN_CM,-1,imod);
|
||||
ivrefcomp=setDACRegister(VREF_COMP,-1,imod);
|
||||
iibtestc=setDACRegister(IB_TESTC,-1,imod);
|
||||
|
||||
if (ivrefds!=vrefds[isett] || ivcascn!=vcascn[isett] || ivcascp!=vcascp[isett] ||
|
||||
ivoutcm!=voutcm[isett] || ivcascout!=vcascout[isett] || ivincm!=vincm[isett] ||
|
||||
ivrefcomp!=vrefcomp[isett] || iibtestc!=ibtestc[isett] ) {
|
||||
|
||||
isett=UNDEFINED;
|
||||
#ifdef VERBOSE
|
||||
printf("Settings of module %d are undefined\n",imod);
|
||||
printf("%d %d %d %d %d %d %d %d \n", ivrefds,ivcascn,ivcascp,ivoutcm,ivcascout,ivincm,ivrefcomp,iibtestc);
|
||||
//commented out by dhanya,should be changed back after firmware update
|
||||
//printf("dacs 1: %08x dacs2: %08x\n",bus_r(MOD_DACS1_REG+(imod<<SHIFTMOD)), bus_r(MOD_DACS2_REG+(imod<<SHIFTMOD)));
|
||||
#endif
|
||||
}
|
||||
//if error while read/writing
|
||||
if(isett==UNDEFINED)
|
||||
printf("Error:Weird Value read back from the Gain/Settings Reg\n");
|
||||
else{
|
||||
//validating the settings read back
|
||||
if((retval>=HIGHGAIN)&&(retval<=VERYHIGHGAIN))
|
||||
isett=retval;
|
||||
else{
|
||||
isett==UNDEFINED;
|
||||
printf("Error:Wrong Settings Read out:%d\n",retval);
|
||||
}
|
||||
}
|
||||
|
||||
thisSettings=isett;
|
||||
#ifdef VERBOSE
|
||||
printf("detector settings are %d and confGain is %d\n",isett,initConfGainByModule(-1,-1));
|
||||
printf("detector settings are %d\n",thisSettings);
|
||||
#endif
|
||||
if (isett==UNDEFINED && thisSettings==UNINITIALIZED)
|
||||
;
|
||||
else
|
||||
thisSettings=isett;
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
@ -1652,17 +1588,10 @@ int initModulebyNumber(sls_detector_module myMod) {
|
||||
copyModule(detectorModules+im,&myMod);
|
||||
}
|
||||
}
|
||||
thisSettings=UNDEFINED;
|
||||
setSettings(GET_SETTINGS);
|
||||
int confgain[] = CONF_GAIN;
|
||||
if ((thisSettings>=HIGHGAIN) && (thisSettings<= VERYHIGHGAIN)) {
|
||||
int retval=initConfGainByModule(confgain[thisSettings],imod);
|
||||
if(retval!=confgain[thisSettings]){
|
||||
printf("Weird Value read from the confGain Reg, changing settings to UNDEFINED",retval);
|
||||
thisSettings=UNDEFINED;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//setting the conf gain and the settings register
|
||||
setSettings(myMod.reg,imod);
|
||||
|
||||
return myMod.reg;
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,6 @@
|
||||
#define RGSH2VALS {260,300,260}
|
||||
|
||||
//high,dynamic,low,medium,very high
|
||||
#define VREFDS_VALS {0,0,200,300,400,500,600}
|
||||
#define VCASCN_VALS {0,0,220,320,420,520,620}
|
||||
#define VCASCP_VALS {0,0,240,340,440,540,640}
|
||||
#define VOUTCM_VALS {0,0,260,360,460,560,660}
|
||||
#define VCASCOUT_VALS {0,0,280,380,480,580,680}
|
||||
#define VINCM_VALS {0,0,300,400,500,600,700}
|
||||
#define VREFCOMP_VALS {0,0,320,420,520,620,720}
|
||||
#define IBTESTC_VALS {0,0,340,440,540,640,740}
|
||||
#define CONF_GAIN {0,0, 0, 1, 6, 2, 1}//dynamic gain confgain yet to be figured out-probably 8 or 16
|
||||
|
||||
|
||||
@ -115,7 +107,7 @@ int program_one_dac(int addr, int value,int imod );
|
||||
int set_one_dac(int imod);
|
||||
int initDAC(int dac_addr, int value,int imod );
|
||||
int initDACs(int* v,int imod );
|
||||
int setSettings(int i);
|
||||
int setSettings(int i,int imod);
|
||||
float initDACbyIndex(int ind,float val, int imod);
|
||||
float initDACbyIndexDACU(int ind,int val, int imod);
|
||||
float getDACbyIndexDACU(int ind, int imod);
|
||||
@ -125,7 +117,7 @@ int setThresholdEnergy(int ethr);
|
||||
/* Other DAC index routines*/
|
||||
float getTemperatureByModule(int tempSensor, int imod);
|
||||
int initHighVoltageByModule(int val, int imod);
|
||||
int initConfGainByModule(int val, int imod);
|
||||
int initConfGainByModule(int isettings,int val,int imod);
|
||||
|
||||
/* Initialization*/
|
||||
int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts,int imod );
|
||||
|
@ -207,33 +207,32 @@
|
||||
/* multi purpose register */
|
||||
#define PHASE_STEP_BIT 0x00000001
|
||||
#define PHASE_STEP_OFFSET 0
|
||||
|
||||
/* #define READOUT_BUSY_BIT 0x00000002
|
||||
#define FIFOTEST_BUSY_BIT 0x00000004
|
||||
#define WAITING_FOR_TRIGGER_BIT 0x00000008
|
||||
#define DELAYBEFORE_BIT 0x00000010 */
|
||||
|
||||
#define SW1_BIT 0x00000020
|
||||
#define SW1_OFFSET 5
|
||||
|
||||
#define WRITE_BACK_BIT 0x00000040
|
||||
#define WRITE_BACK_OFFSET 6
|
||||
|
||||
#define RESET_BIT 0x00000080
|
||||
#define RESET_OFFSET 7
|
||||
|
||||
#define ENET_RESETN_BIT 0x00000800
|
||||
#define ENET_RESETN_OFFSET 11
|
||||
|
||||
#define INT_RSTN_BIT 0x00002000
|
||||
#define INT_RSTN_OFFSET 13
|
||||
|
||||
#define DIGITAL_TEST_BIT 0x00004000
|
||||
#define DIGITAL_TEST_OFFSET 14
|
||||
|
||||
#define CHANGE_AT_POWER_ON_BIT 0x00008000
|
||||
#define CHANGE_AT_POWER_ON_OFFSET 15
|
||||
|
||||
|
||||
/* settings/conf gain register */
|
||||
#define GAIN_MASK 0x0000000f
|
||||
#define GAIN_OFFSET 0
|
||||
#define SETTINGS_MASK 0x000000f0
|
||||
#define SETTINGS_OFFSET 4
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -73,7 +73,7 @@ int init_detector( int b) {
|
||||
setDummyRegister();
|
||||
setPhaseShiftOnce();
|
||||
setDAQRegister();
|
||||
setSettings(GET_SETTINGS);
|
||||
setSettings(GET_SETTINGS,-1);
|
||||
|
||||
|
||||
//testRAM();
|
||||
@ -1435,10 +1435,6 @@ int set_module(int file_des) {
|
||||
} else {
|
||||
#ifdef MCB_FUNCS
|
||||
retval=initModulebyNumber(myModule);
|
||||
if(retval==-1){
|
||||
ret=FAIL;
|
||||
strcpy(mess,"Cannot set this settings as confGain register read back weird value\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1712,10 +1708,10 @@ int set_settings(int file_des) {
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
#ifdef MCB_FUNCS
|
||||
retval=setSettings(arg[0]);
|
||||
retval=setSettings(arg[0],imod);
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
printf("Settings changed to %d\n", isett);
|
||||
printf("Settings changed to %d\n",retval);
|
||||
#endif
|
||||
|
||||
if (retval==isett || isett<0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user