mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
gotthard server works, fine tuning left
This commit is contained in:
parent
06a6d53a3f
commit
4b007b003a
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_refactor
Executable file
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_refactor
Executable file
Binary file not shown.
@ -1,9 +1,9 @@
|
|||||||
Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer
|
Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer
|
||||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||||
Repsitory UUID: bfda07d262dd4eb8c8298df6809d0172d10076e5
|
Repsitory UUID: 06a6d53a3f1c5aeeced47475057f956b72d9a74f
|
||||||
Revision: 14
|
Revision: 15
|
||||||
Branch: refactor
|
Branch: refactor
|
||||||
Last Changed Author: Dhanya_Thattil
|
Last Changed Author: Dhanya_Thattil
|
||||||
Last Changed Rev: 4199
|
Last Changed Rev: 4200
|
||||||
Last Changed Date: 2019-01-04 12:28:36.000000002 +0100 ./.target-makefrag
|
Last Changed Date: 2019-01-07 12:06:28.000000002 +0100 ./.target-makefrag
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||||
#define GITREPUUID "bfda07d262dd4eb8c8298df6809d0172d10076e5"
|
#define GITREPUUID "06a6d53a3f1c5aeeced47475057f956b72d9a74f"
|
||||||
#define GITAUTH "Dhanya_Thattil"
|
#define GITAUTH "Dhanya_Thattil"
|
||||||
#define GITREV 0x4199
|
#define GITREV 0x4200
|
||||||
#define GITDATE 0x20190104
|
#define GITDATE 0x20190107
|
||||||
#define GITBRANCH "refactor"
|
#define GITBRANCH "refactor"
|
||||||
|
@ -391,13 +391,14 @@ void setupDetector() {
|
|||||||
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK);
|
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK);
|
||||||
bus_w(TEMP_SPI_OUT_REG, 0x0);
|
bus_w(TEMP_SPI_OUT_REG, 0x0);
|
||||||
|
|
||||||
|
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
if (getBoardRevision() == 1)
|
if (getBoardRevision() == 1)
|
||||||
AD9252_Configure();
|
AD9252_Configure();
|
||||||
else
|
else
|
||||||
AD9257_Configure();
|
AD9257_Configure();
|
||||||
#endif
|
#endif
|
||||||
//configureADC();
|
|
||||||
setROIADC(-1); // set adcsyncreg, daqreg, chipofinterestreg, cleanfifos,
|
setROIADC(-1); // set adcsyncreg, daqreg, chipofinterestreg, cleanfifos,
|
||||||
setGbitReadout();
|
setGbitReadout();
|
||||||
LTC2620_Configure(); /*FIXME: if it doesnt work, switch to the old dac*/
|
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));
|
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() {
|
void cleanFifos() {
|
||||||
FILE_LOG(logINFO, ("Cleaning FIFOs\n"));
|
FILE_LOG(logINFO, ("Cleaning FIFOs\n"));
|
||||||
bus_w(ADC_SYNC_REG, bus_r(ADC_SYNC_REG) | ADC_SYNC_CLEAN_FIFOS_MSK);
|
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;
|
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){
|
int getADC(enum ADCINDEX ind){
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
@ -1354,8 +1205,11 @@ int setHighVoltage(int val){
|
|||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG1, ("\tHigh voltage value to be sent: 0x%x\n", sel));
|
FILE_LOG(logDEBUG1, ("\tHigh voltage value to be sent: 0x%x\n", sel));
|
||||||
|
|
||||||
// switch off high voltage and set value
|
// switch off high voltage
|
||||||
bus_w(addr, (bus_r(addr) & ~HV_ENBL_MSK) | sel);
|
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
|
// switch on high voltage
|
||||||
if (val > 0)
|
if (val > 0)
|
||||||
|
@ -205,8 +205,12 @@ void AD9257_Configure(){
|
|||||||
AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_BINARY_OFST_VAL);
|
AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_BINARY_OFST_VAL);
|
||||||
|
|
||||||
//output clock phase
|
//output clock phase
|
||||||
FILE_LOG(logINFO, ("\tOutput clock phase\n")); //FIXME:??
|
#ifdef GOTTHARDD
|
||||||
|
FILE_LOG(logINFO, ("\tOutput clock phase is at default: 180\n"));
|
||||||
|
#else
|
||||||
|
FILE_LOG(logINFO, ("\tOutput clock phase: 60\n"));
|
||||||
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_60_VAL);
|
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_60_VAL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// lvds-iee reduced , binary offset
|
// lvds-iee reduced , binary offset
|
||||||
FILE_LOG(logINFO, ("\tLvds-iee reduced, binary offset\n"));
|
FILE_LOG(logINFO, ("\tLvds-iee reduced, binary offset\n"));
|
||||||
@ -216,18 +220,18 @@ void AD9257_Configure(){
|
|||||||
FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
||||||
AD9257_Set(AD9257_DEV_IND_2_REG,
|
AD9257_Set(AD9257_DEV_IND_2_REG,
|
||||||
AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK);
|
AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK);
|
||||||
#ifdef GOTTHARDD
|
|
||||||
AD9257_Set(AD9257_DEV_IND_1_REG,
|
|
||||||
AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK );// FIXME: gotthard setting dco and ifco to off??
|
|
||||||
#else
|
|
||||||
AD9257_Set(AD9257_DEV_IND_1_REG,
|
AD9257_Set(AD9257_DEV_IND_1_REG,
|
||||||
AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK |
|
AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK |
|
||||||
AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK);
|
AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK);
|
||||||
#endif
|
|
||||||
|
|
||||||
// vref 1.33
|
// vref
|
||||||
FILE_LOG(logINFO, ("\tVref 1.33\n"));// FIXME: needed for Gottthard? earlier not set (default 3.0 v)
|
#ifdef GOTTHARDD
|
||||||
|
FILE_LOG(logINFO, ("\tVref default at 2.0\n"));
|
||||||
|
#else
|
||||||
|
FILE_LOG(logINFO, ("\tVref 1.33\n"));
|
||||||
AD9257_Set(AD9257_VREF_REG, AD9257_VREF_1_33_VAL);
|
AD9257_Set(AD9257_VREF_REG, AD9257_VREF_1_33_VAL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// no test mode
|
// no test mode
|
||||||
FILE_LOG(logINFO, ("\tNo test mode\n"));
|
FILE_LOG(logINFO, ("\tNo test mode\n"));
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* LTC2620 DAC DEFINES */
|
/* LTC2620 DAC DEFINES */
|
||||||
// first 4 bits are 0 as this is a 12 bit dac
|
// first 4 bits are 0 as this is a 12 bit dac
|
||||||
@ -190,6 +191,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
|||||||
* @param chipIndex the chip to be set
|
* @param chipIndex the chip to be set
|
||||||
*/
|
*/
|
||||||
void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) {
|
void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) {
|
||||||
|
FILE_LOG(logDEBUG1, ("\tcmd:%d data:%d dacaddr:%d chipIndex:%d\n", cmd, data, dacaddr, chipIndex));
|
||||||
// ctb
|
// ctb
|
||||||
if (LTC2620_Ndac > LTC2620_NUMCHANNELS)
|
if (LTC2620_Ndac > LTC2620_NUMCHANNELS)
|
||||||
LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex);
|
LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex);
|
||||||
@ -243,10 +245,9 @@ void LTC2620_SetDAC (int dacnum, int data) {
|
|||||||
FILE_LOG(logDEBUG1,("\tWrite to Input Register and Update\n"));
|
FILE_LOG(logDEBUG1,("\tWrite to Input Register and Update\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
LTC2620_Set(data, addr, cmd, ichip);
|
LTC2620_Set(cmd, data, addr, ichip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set dac in dac units or mV
|
* Set dac in dac units or mV
|
||||||
* @param dacnum dac index
|
* @param dacnum dac index
|
||||||
@ -256,6 +257,7 @@ void LTC2620_SetDAC (int dacnum, int data) {
|
|||||||
* @returns OK or FAIL for success of operation
|
* @returns OK or FAIL for success of operation
|
||||||
*/
|
*/
|
||||||
int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
||||||
|
FILE_LOG(logDEBUG1, ("\tdacnum:%d, val:%d, mV:%d\n", dacnum, val, mV));
|
||||||
// validate index
|
// validate index
|
||||||
if (dacnum < 0 || dacnum >= LTC2620_Ndac) {
|
if (dacnum < 0 || dacnum >= LTC2620_Ndac) {
|
||||||
FILE_LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_Ndac - 1));
|
FILE_LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_Ndac - 1));
|
||||||
@ -289,5 +291,3 @@ int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
|||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,6 @@ void resetPeripheral();
|
|||||||
#elif GOTTHARDD
|
#elif GOTTHARDD
|
||||||
void setPhaseShiftOnce();
|
void setPhaseShiftOnce();
|
||||||
void setPhaseShift(int numphaseshift);
|
void setPhaseShift(int numphaseshift);
|
||||||
void configureADC();
|
|
||||||
void cleanFifos();
|
void cleanFifos();
|
||||||
void setADCSyncRegister();
|
void setADCSyncRegister();
|
||||||
void setDAQRegister();
|
void setDAQRegister();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user