mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-06 21:00:02 +02:00
gotthard:incorporated the temperature read
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@52 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
fc07eee532
commit
40e945889c
@ -225,7 +225,6 @@ u_int32_t putout(char *s, int modnum) {
|
||||
}
|
||||
//addr=MCB_CNTRL_REG_OFF+(modnum<<4);
|
||||
addr=MCB_CNTRL_REG_OFF;//+(modnum<<SHIFTMOD); commented by dhanya
|
||||
//printf("\n\tpat=");showbits(pat);
|
||||
bus_w(addr, pat);
|
||||
|
||||
return OK;
|
||||
@ -806,8 +805,6 @@ int setDACRegister(int idac, int val, int imod) {
|
||||
u_int32_t addr, reg, mask;
|
||||
int off;
|
||||
#ifdef VERBOSE
|
||||
printf("\ninside setdacref.....\n");
|
||||
printf("val=%d\n",val);
|
||||
printf("Settings dac %d module %d register to %d\n",idac,imod,val);
|
||||
#endif
|
||||
|
||||
@ -855,6 +852,41 @@ int setDACRegister(int idac, int val, int imod) {
|
||||
}
|
||||
|
||||
|
||||
float getTemperature(int tempSensor, int imod)
|
||||
{
|
||||
float val;
|
||||
char cTempSensor[2][100]={"ADCs/ASICs","VRs/FPGAs"};
|
||||
imod=0;//ignoring more than 1 mod for now
|
||||
int i,j,k,repeats=6,times=11;
|
||||
u_int32_t tempVal=0;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Getting Temperature of module:%d for the %s\n",imod,cTempSensor[tempSensor]);
|
||||
#endif
|
||||
bus_w(TEMP_SPI_IN,T1_CLK_BIT|T1_CS_BIT|T2_CLK_BIT|T2_CS_BIT);//standby
|
||||
bus_w(TEMP_SPI_IN,(T1_CLK_BIT)&~(T1_CS_BIT)|(T2_CLK_BIT));//high clk low cs
|
||||
|
||||
for(k=0;k<2;k++){
|
||||
for(i=0;i<times;i++) {
|
||||
//repeats is number of register writes for delay
|
||||
for(j=0;j<repeats;j++)
|
||||
bus_w(TEMP_SPI_IN,~(T1_CLK_BIT)&~(T1_CS_BIT)&~(T2_CLK_BIT)&~(T2_CS_BIT));//low clk low cs
|
||||
for(j=0;j<repeats;j++)
|
||||
bus_w(TEMP_SPI_IN,(T1_CLK_BIT)&~(T1_CS_BIT)|(T2_CLK_BIT));//high clk low cs
|
||||
|
||||
if(times==11)//only the first time
|
||||
tempVal= (tempVal<<1) + (bus_r(TEMP_SPI_OUT) & (1<<tempSensor));
|
||||
}
|
||||
times=8;
|
||||
}
|
||||
bus_w(TEMP_SPI_IN,T1_CLK_BIT|T1_CS_BIT|T2_CLK_BIT|T2_CS_BIT);//standby
|
||||
val=((float)tempVal)/4.0;
|
||||
|
||||
#ifdef VERBOSE//read time from start needed??
|
||||
printf("Temperature of module:%d for the %s is %.2fC\n",imod,cTempSensor[tempSensor],val);
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
u_int32_t runBusy(void) {
|
||||
|
@ -46,6 +46,7 @@ int setContinousReadOut(int d);
|
||||
|
||||
int setDACRegister(int idac, int val, int imod);
|
||||
|
||||
float getTemperature(int tempSensor, int imod);
|
||||
|
||||
u_int64_t getMcsNumber();
|
||||
u_int32_t getMcsVersion();
|
||||
|
@ -25,18 +25,14 @@
|
||||
|
||||
|
||||
// DAC definitions
|
||||
|
||||
enum {VREF_DS, VCASCN_PB, VCASCP_PB, VOUT_CM, VCASC_OUT, VIN_CM, VREF_COMP, IB_TESTC};
|
||||
|
||||
|
||||
/* DAC adresses */
|
||||
//#define DACCS {0,0,1,1,2,2}
|
||||
//#define DACADDR {0,1,0,1,0,1}
|
||||
|
||||
/* DAC adresses */
|
||||
#define DACCS {0,0,1,1,2,2,3,3,4,4,5,5,6,6}
|
||||
#define DACADDR {0,1,0,1,0,1,0,1,0,1,0,1,0,1}
|
||||
|
||||
//Temp definitions
|
||||
enum {TEMP_ADC, TEMP_FPGA};
|
||||
|
||||
//dynamic range
|
||||
#define MAX5523
|
||||
|
@ -20,6 +20,10 @@
|
||||
#define GAIN_REG 0x10<<11
|
||||
#define DAQ_REG 0x1b<<11
|
||||
|
||||
//temperature
|
||||
#define TEMP_SPI_IN 0x81<<11
|
||||
#define TEMP_SPI_OUT 0x82<<11
|
||||
|
||||
//not used so far
|
||||
#define SPEED_REG 0x006000
|
||||
#define SET_NBITS_REG 0x008000
|
||||
@ -160,6 +164,13 @@
|
||||
#define EXT_RO_TRIG_OUT_FALLING 0xC
|
||||
|
||||
|
||||
/* for temperature register */
|
||||
#define T1_CLK_BIT 0x00000001
|
||||
#define T1_CS_BIT 0x00000002
|
||||
#define T2_CLK_BIT 0x00000004
|
||||
#define T2_CS_BIT 0x00000008
|
||||
|
||||
|
||||
|
||||
/* fifo control register */
|
||||
#define FIFO_RESET_BIT 0x00000001
|
||||
@ -167,7 +178,6 @@
|
||||
|
||||
|
||||
//chip shiftin register meaning
|
||||
|
||||
#define OUTMUX_OFF 20
|
||||
#define OUTMUX_MASK 0x1f
|
||||
#define PROBES_OFF 4
|
||||
@ -176,3 +186,4 @@
|
||||
#define OUTBUF_MASK 1
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -792,8 +792,9 @@ int set_dac(int fnum) {
|
||||
int n;
|
||||
float val;
|
||||
int idac=0;
|
||||
int itemp=-1;
|
||||
|
||||
sprintf(mess,"Can't set DAC\n");
|
||||
sprintf(mess,"Can't set DAC/POT/TEMP\n");
|
||||
|
||||
|
||||
n = receiveDataOnly(arg,sizeof(arg));
|
||||
@ -811,7 +812,7 @@ int set_dac(int fnum) {
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Setting DAC %d of module %d to %f V\n", ind, imod, val);
|
||||
printf("Setting DAC/POT/TEMP %d of module %d to %f V\n", ind, imod, val);
|
||||
#endif
|
||||
|
||||
if (imod>=getNModBoard())
|
||||
@ -845,25 +846,39 @@ int set_dac(int fnum) {
|
||||
case G_IB_TESTC:
|
||||
idac=IB_TESTC;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown DAC index %d\n",ind);
|
||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||
case TEMPERATURE_ADC:
|
||||
itemp=TEMP_ADC;
|
||||
break;
|
||||
case TEMPERATURE_FPGA:
|
||||
itemp=TEMP_FPGA;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown DAC/POT/TEMP index %d\n",ind);
|
||||
sprintf(mess,"Unknown DAC/POT/TEMP index %d\n",ind);
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
if (ret==OK) {
|
||||
if(itemp!=-1) {
|
||||
if (imod>=0 && imod<nModX)
|
||||
retval=getTemperature(itemp,imod);
|
||||
else
|
||||
//get only the first mods temp, but dunno when this is used
|
||||
retval=getTemperature(itemp,0);
|
||||
}
|
||||
else
|
||||
retval=initDACbyIndexDACU(idac,val,imod);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("DAC set to %f V\n", retval);
|
||||
printf("DAC/POT/TEMP set to %f V\n", retval);
|
||||
#endif
|
||||
if (retval==val || val==-1)
|
||||
ret=OK;
|
||||
else {
|
||||
ret=FAIL;
|
||||
printf("Setting dac %d of module %d: wrote %f but read %f\n", ind, imod, val, retval);
|
||||
printf("Setting dac/pot %d of module %d: wrote %f but read %f\n", ind, imod, val, retval);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user