gotthard server works, fine tuning left

This commit is contained in:
2019-01-08 06:52:28 +01:00
parent 06a6d53a3f
commit 4b007b003a
7 changed files with 31 additions and 174 deletions

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: bfda07d262dd4eb8c8298df6809d0172d10076e5
Revision: 14
Repsitory UUID: 06a6d53a3f1c5aeeced47475057f956b72d9a74f
Revision: 15
Branch: refactor
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4199
Last Changed Date: 2019-01-04 12:28:36.000000002 +0100 ./.target-makefrag
Last Changed Rev: 4200
Last Changed Date: 2019-01-07 12:06:28.000000002 +0100 ./.target-makefrag

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "bfda07d262dd4eb8c8298df6809d0172d10076e5"
#define GITREPUUID "06a6d53a3f1c5aeeced47475057f956b72d9a74f"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4199
#define GITDATE 0x20190104
#define GITREV 0x4200
#define GITDATE 0x20190107
#define GITBRANCH "refactor"

View File

@ -391,13 +391,14 @@ void setupDetector() {
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK);
bus_w(TEMP_SPI_OUT_REG, 0x0);
#ifndef VIRTUAL
if (getBoardRevision() == 1)
AD9252_Configure();
else
AD9257_Configure();
#endif
//configureADC();
setROIADC(-1); // set adcsyncreg, daqreg, chipofinterestreg, cleanfifos,
setGbitReadout();
LTC2620_Configure(); /*FIXME: if it doesnt work, switch to the old dac*/
@ -487,65 +488,6 @@ void setPhaseShift(int numphaseshift) {
FILE_LOG(logDEBUG1, ("Multipurpose reg: 0x%x\n", val));
}
void configureADC() {
printf("Preparing ADC\n");
u_int32_t valw,codata,csmask;
int i,j,cdx,ddx;
cdx=0; ddx=1;
csmask=0x7c; // 1111100
for(j=0;j<3;j++){
//command and value;
codata = 0;
if(j==0)
codata=(0x08<<8)+(0x3);//Power modes(global) //reset
else if(j==1)
codata=(0x08<<8)+(0x0);//Power modes(global) //chip run
else
codata = (0x14<<8)+(0x0);//Output mode //offset binary
// start point
valw=0xffffffff;
bus_w(ADC_SPI_REG,(valw));
//chip sel bar down
valw=((0xffffffff&(~csmask)));
bus_w(ADC_SPI_REG,valw);
for (i=0;i<24;i++) {
//cldwn
valw=valw&(~(0x1<<cdx));
bus_w(ADC_SPI_REG,valw);
//usleep(0);
//write data (i)
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx);
bus_w(ADC_SPI_REG,valw);
//usleep(0);
//clkup
valw=valw+(0x1<<cdx);
bus_w(ADC_SPI_REG,valw);
//usleep(0);
}
valw |= csmask;
bus_w(ADC_SPI_REG,valw);
//usleep(0);
// stop point =start point
valw=valw&(~(0x1<<cdx));
bus_w(ADC_SPI_REG,(valw));
valw = 0xffffffff;
bus_w(ADC_SPI_REG,(valw));
//usleep in between
usleep(50000);
}
}
void cleanFifos() {
FILE_LOG(logINFO, ("Cleaning FIFOs\n"));
bus_w(ADC_SYNC_REG, bus_r(ADC_SYNC_REG) | ADC_SYNC_CLEAN_FIFOS_MSK);
@ -1172,97 +1114,6 @@ int getMaxDacSteps() {
return LTC2620_MAX_STEPS;
}
/*
void setDAC(enum DACINDEX ind, int val, int mV, int retval[]) {
int dacmV = val;
//if set and mv, convert to dac
if (val > 0) {
if (mV)
val = voltageToDac(val); //gives -1 on error
else
dacmV = dacToVoltage(val); //gives -1 on error
}
if (val >= 0) {
FILE_LOG(logINFO, ("Setting DAC %d: %d dac (%d mV)\n",ind, val, dacmV));
#ifndef VIRTUAL
initDAC(ind,val);
clearDACSregister();
#else
dacValues[ind] = val;
#endif
}
retval[0] = dacValues[ind];
retval[1] = dacToVoltage(retval[0]);
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, retval[0], retval[1]));
}
void initDAC(int dac_addr, int value) {
FILE_LOG(logDEBUG1, ("Programming dac %d with value %d\n", dac_addr, value));
clearDACSregister();
if (value >= 0)
program_one_dac(dac_addr,value);
nextDAC();
}
void clearDACSregister() {
putout("1111111111111111");//reset
putout("1111111111111110");//cs down
}
void nextDAC() {
putout("1111111111111011");//cs up
putout("1111111111111001");//clk down
putout("1111111111111111");//reset
}
void program_one_dac(int addr, int value) {
FILE_LOG(logDEBUG1, ("Programming dac %d with value %d\n", addr, value));
int origValue = value;
int control = 32 + addr;
value = (value << 4) | (control << 16);
{
int i = 0;
for (i = 0; i < 24; ++i) {
int bit = value & (1 << (23 - i));
if (bit) {
putout("1111111111111100");//clk down
putout("1111111111111100");//write data
putout("1111111111111110");//clk up
}
else
{
putout("1111111111111000");//clk down
putout("1111111111111000");//write data
putout("1111111111111010");//clk up
}
}
}
dacValues[addr] = origValue;
FILE_LOG(logDEBUG1, ("\tDac %d set to %dn", addr, origValue));
}
// direct pattern output
u_int32_t putout(char *s) {
if (strlen(s)<16) {
FILE_LOG(logERROR, ("putout: incorrect pattern length\n"));
return FAIL;
}
u_int32_t pat=0;
{int i = 0;
for (i = 0; i < 16; ++i) {
if (s[i]=='1')
pat = pat + (1 << (15 - i));
}
}
bus_w(DAC_CNTRL_REG, pat);
return OK;
}
*/
int getADC(enum ADCINDEX ind){
#ifdef VIRTUAL
@ -1354,8 +1205,11 @@ int setHighVoltage(int val){
}
FILE_LOG(logDEBUG1, ("\tHigh voltage value to be sent: 0x%x\n", sel));
// switch off high voltage and set value
bus_w(addr, (bus_r(addr) & ~HV_ENBL_MSK) | sel);
// switch off high voltage
bus_w(addr, (bus_r(addr) & ~HV_ENBL_MSK));
// unset mask and set value
bus_w(addr, (bus_r(addr) & ~HV_SEL_MSK) | sel);
// switch on high voltage
if (val > 0)