jungfrau server: added deg and maxadcphaseshift, ctb & moench server: set adc phase like jungfrau that positive shift is positive, moved conversion between shift to degrees to the common function. receiver: removed unused variables

This commit is contained in:
maliakal_d 2019-03-28 09:35:53 +01:00
parent 5a4122ae7c
commit c38bebd615
14 changed files with 152 additions and 132 deletions

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer
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: c7ad548e4c2026a826b9f269f32d9970ce0a44e8 Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7
Revision: 48 Revision: 50
Branch: refactor Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4478 Last Changed Rev: 4481
Last Changed Date: 2019-03-27 11:13:21.000000002 +0100 ../slsDetectorServer/slsDetectorServer_funcs.c Last Changed Date: 2019-03-28 08:18:03.000000002 +0100 ../slsDetectorServer/slsDetectorFunctionList.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "c7ad548e4c2026a826b9f269f32d9970ce0a44e8" #define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4478 #define GITREV 0x4481
#define GITDATE 0x20190327 #define GITDATE 0x20190328
#define GITBRANCH "refactor" #define GITBRANCH "refactor"

View File

@ -1649,25 +1649,20 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
return; return;
} }
FILE_LOG(logINFO, ("Configuring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees)); FILE_LOG(logINFO, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
int valShift = val; int valShift = val;
// convert to phase shift // convert to phase shift
if (degrees) { if (degrees) {
double temp = val * ((double)maxShift / 360.00); ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
if ((temp - (int)temp) > 0.0001) {
temp += 0.5;
}
valShift = temp;
FILE_LOG(logDEBUG1, ("phase shift: %d\n", valShift));
} }
FILE_LOG(logDEBUG1, ("phase shift: %d (degrees/shift: %d)\n", valShift, val)); FILE_LOG(logDEBUG1, ("phase shift: %d (degrees/shift: %d)\n", valShift, val));
int relativePhase = clkPhase[ind] - valShift; int relativePhase = valShift - clkPhase[ind];
FILE_LOG(logDEBUG1, ("relative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind])); FILE_LOG(logDEBUG1, ("relative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind]));
// same phase // same phase
if (!relativePhase) { if (!relativePhase) {
FILE_LOG(logDEBUG1, ("Nothing to do\n")); FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
return; return;
} }
@ -1687,7 +1682,10 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
int getPhase(enum CLKINDEX ind, int degrees) { int getPhase(enum CLKINDEX ind, int degrees) {
if (!degrees) if (!degrees)
return clkPhase[ind]; return clkPhase[ind];
return (clkPhase[ind] * (360.00 / (double)getMaxPhase(ind))); // convert back to degrees
int val = 0;
ConvertToDifferentRange(0, getMaxPhase(ind) - 1, 0, 359, clkPhase[ind], &val);
return val;
} }
int getMaxPhase(enum CLKINDEX ind) { int getMaxPhase(enum CLKINDEX ind) {
@ -1717,14 +1715,11 @@ int validatePhaseinDegrees(enum speedVariable ind, int val, int retval) {
FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", clkIndex)); FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", clkIndex));
int maxShift = getMaxPhase(clkIndex); int maxShift = getMaxPhase(clkIndex);
// convert degrees to shift // convert degrees to shift
double temp = val; // convert degrees to shift
temp *= ((double)maxShift / 360.00); int valShift = 0;
if ((temp - (int)temp) > 0.0001) { ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
temp += 0.5;
}
val = (int)temp;
// convert back to degrees // convert back to degrees
val *= (360.00 / (double)maxShift); ConvertToDifferentRange(0, maxShift - 1, 0, 359, valShift, &val);
if (val == retval) if (val == retval)
return OK; return OK;
@ -1746,7 +1741,7 @@ void configureFrequency(enum CLKINDEX ind, int val) {
// reset phase // reset phase
if (ind == ADC_CLK || ind == DBIT_CLK) { if (ind == ADC_CLK || ind == DBIT_CLK) {
FILE_LOG(logDEBUG1, ("Reseting phase of %s\n", clock_names[ind])); FILE_LOG(logINFO, ("\tReseting phase of %s\n", clock_names[ind]));
configurePhase(ind, 0, 0); configurePhase(ind, 0, 0);
} }

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer
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: cd5aea895b07b7af25e3fb74a341a861f9aa291c Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7
Revision: 30 Revision: 31
Branch: jungfrau Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4473 Last Changed Rev: 4481
Last Changed Date: 2019-03-26 14:19:40.000000002 +0100 ./slsDetectorFunctionList.c Last Changed Date: 2019-03-28 08:18:03.000000002 +0100 ../slsDetectorServer/slsDetectorFunctionList.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c" #define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4473 #define GITREV 0x4481
#define GITDATE 0x20190326 #define GITDATE 0x20190328
#define GITBRANCH "jungfrau" #define GITBRANCH "refactor"

View File

@ -33,7 +33,7 @@ int virtual_stop = 0;
enum detectorSettings thisSettings = UNINITIALIZED; enum detectorSettings thisSettings = UNINITIALIZED;
int highvoltage = 0; int highvoltage = 0;
int dacValues[NDAC] = {0}; int dacValues[NDAC] = {0};
int32_t clkPhase[2] = {0, 0}; int adcPhase = 0;
int isFirmwareCheckDone() { int isFirmwareCheckDone() {
@ -365,7 +365,6 @@ u_int32_t getDetectorIP(){
/* initialization */ /* initialization */
void initControlServer(){ void initControlServer(){
clkPhase[0] = 0; clkPhase[1] = 0;
setupDetector(); setupDetector();
} }
@ -393,6 +392,7 @@ void initStopServer() {
void setupDetector() { void setupDetector() {
FILE_LOG(logINFO, ("This Server is for 1 Jungfrau module (500k)\n")); FILE_LOG(logINFO, ("This Server is for 1 Jungfrau module (500k)\n"));
adcPhase = 0;
ALTERA_PLL_ResetPLL(); ALTERA_PLL_ResetPLL();
resetCore(); resetCore();
resetPeripheral(); resetPeripheral();
@ -518,23 +518,25 @@ int setDynamicRange(int dr){
/* parameters - speed, readout */ /* parameters - speed, readout */
void setSpeed(enum speedVariable ind, int val) { void setSpeed(enum speedVariable ind, int val, int mode) {
switch(ind) { switch(ind) {
case CLOCK_DIVIDER: case CLOCK_DIVIDER:
setClockDivider(val); setClockDivider(val);
case ADC_PHASE: case ADC_PHASE:
setAdcPhase(val); setAdcPhase(val, mode);
default: default:
return; return;
} }
} }
int getSpeed(enum speedVariable ind) { int getSpeed(enum speedVariable ind, int mode) {
switch(ind) { switch(ind) {
case CLOCK_DIVIDER: case CLOCK_DIVIDER:
return getClockDivider(); return getClockDivider();
case ADC_PHASE: case ADC_PHASE:
return getPhase(); return getPhase(mode);
case MAX_ADC_PHASE_SHIFT:
return getMaxPhaseShift();
default: default:
return -1; return -1;
} }
@ -1210,7 +1212,7 @@ void setClockDivider(int val) {
bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
FILE_LOG(logINFO, ("\tSetting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED)); FILE_LOG(logINFO, ("\tSetting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED));
setAdcPhase(ADC_PHASE_HALF_SPEED); setAdcPhase(ADC_PHASE_HALF_SPEED, 0);
break; break;
case HALF_SPEED: case HALF_SPEED:
@ -1227,7 +1229,7 @@ void setClockDivider(int val) {
bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_HALF_SPEED_VAL);
FILE_LOG(logINFO, ("\tSetting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED)); FILE_LOG(logINFO, ("\tSetting ADC Phase Reg to 0x%x\n", ADC_PHASE_HALF_SPEED));
setAdcPhase(ADC_PHASE_HALF_SPEED); setAdcPhase(ADC_PHASE_HALF_SPEED, 0);
break; break;
case QUARTER_SPEED: case QUARTER_SPEED:
@ -1244,7 +1246,7 @@ void setClockDivider(int val) {
bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL); bus_w(ADC_OFST_REG, ADC_OFST_QUARTER_SPEED_VAL);
FILE_LOG(logINFO, ("\tSetting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED)); FILE_LOG(logINFO, ("\tSetting ADC Phase Reg to 0x%x\n", ADC_PHASE_QUARTER_SPEED));
setAdcPhase(ADC_PHASE_QUARTER_SPEED); setAdcPhase(ADC_PHASE_QUARTER_SPEED, 0);
break; break;
} }
@ -1265,51 +1267,77 @@ int getClockDivider() {
} }
} }
int setAdcPhase(int st){ /**carlos needed clkphase 1 and 2? cehck with Aldo */ void setAdcPhase(int val, int degrees){
FILE_LOG(logINFO, ("Setting ADC Phase to %d\n", st)); int maxShift = MAX_PHASE_SHIFTS;
if (st > 65535 || st < -65535)
return clkPhase[0];
clkPhase[1] = st - clkPhase[0]; // validation
if (clkPhase[1] == 0) if (degrees && (val < 0 || val > 359)) {
return clkPhase[0]; FILE_LOG(logERROR, ("\tPhase provided outside limits (0 - 359°C)\n"));
configurePll();
clkPhase[0] = st;
return clkPhase[0];
}
int getPhase() {
return clkPhase[0];
}
void configurePll() {
#ifdef VIRTUAL
return; return;
#endif }
int32_t phase=0; if (!degrees && (val < 0 || val > MAX_PHASE_SHIFTS - 1)) {
// ensuring PLL is never configured with same phase FILE_LOG(logERROR, ("\tPhase provided outside limits (0 - %d phase shifts)\n", maxShift - 1));
if (clkPhase[1] == 0) {
return; return;
} }
FILE_LOG(logINFO, ("\tConfiguring PLL with phase in %d\n", clkPhase[1])); FILE_LOG(logINFO, ("Setting ADC Phase to %d (degree mode: %d)\n", val, degrees));
int valShift = val;
// delay ADC clk // convert to phase shift
if (clkPhase[1]>0) { if (degrees) {
phase = MAX_PHASE_SHIFTS - clkPhase[1]; ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
} }
// advance adc clk FILE_LOG(logDEBUG1, ("phase shift: %d (degrees/shift: %d)\n", valShift, val));
else {
phase = (-1) * clkPhase[1]; int relativePhase = valShift - adcPhase;
FILE_LOG(logDEBUG1, ("relative phase shift: %d (Current phase: %d)\n", relativePhase, adcPhase));
// same phase
if (!relativePhase) {
FILE_LOG(logINFO, ("Nothing to do in Phase Shift\n"));
return;
} }
FILE_LOG(logDEBUG1, ("\tphase out %d (0x%08x)\n", phase, phase)); int phase = 0;
ALTERA_PLL_SetPhaseShift(phase, 1, 0); // phase, 1: adc clk, 0:neg if (relativePhase > 0) {
usleep(10000); phase = (maxShift - relativePhase);
} else {
phase = (-1) * relativePhase;
}
FILE_LOG(logDEBUG1, ("[Single Direction] Phase:%d (0x%x). Max Phase shifts:%d\n", phase, phase, maxShift));
ALTERA_PLL_SetPhaseShift(phase, 1, 0);
adcPhase = valShift;
} }
int getPhase(degrees) {
if (!degrees)
return adcPhase;
// convert back to degrees
int val = 0;
ConvertToDifferentRange(0, MAX_PHASE_SHIFTS - 1, 0, 359, adcPhase, &val);
return val;
}
int getMaxPhaseShift() {
return MAX_PHASE_SHIFTS;
}
int validatePhaseinDegrees(int val, int retval) {
if (val == -1)
return OK;
FILE_LOG(logDEBUG1, ("validating phase in degrees\n"));
int maxShift = MAX_PHASE_SHIFTS;
// convert degrees to shift
int valShift = 0;
ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
// convert back to degrees
ConvertToDifferentRange(0, maxShift - 1, 0, 359, valShift, &val);
if (val == retval)
return OK;
return FAIL;
}
int setThresholdTemperature(int val) { int setThresholdTemperature(int val) {

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer
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: 7cd5bc8b2db6e89fbec4c06c65e683cf788338c0 Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7
Revision: 22 Revision: 26
Branch: jungfrau Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4474 Last Changed Rev: 4481
Last Changed Date: 2019-03-26 15:01:04.000000002 +0100 ./slsDetectorServer_defs.h Last Changed Date: 2019-03-28 09:08:53.000000002 +0100 ./slsDetectorFunctionList.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "7cd5bc8b2db6e89fbec4c06c65e683cf788338c0" #define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4474 #define GITREV 0x4481
#define GITDATE 0x20190326 #define GITDATE 0x20190328
#define GITBRANCH "jungfrau" #define GITBRANCH "refactor"

View File

@ -1285,25 +1285,20 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
return; return;
} }
FILE_LOG(logINFO, ("Configuring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees)); FILE_LOG(logINFO, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
int valShift = val; int valShift = val;
// convert to phase shift // convert to phase shift
if (degrees) { if (degrees) {
double temp = val * ((double)maxShift / 360.00); ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
if ((temp - (int)temp) > 0.0001) {
temp += 0.5;
}
valShift = temp;
FILE_LOG(logDEBUG1, ("phase shift: %d\n", valShift));
} }
FILE_LOG(logDEBUG1, ("phase shift: %d (degrees/shift: %d)\n", valShift, val)); FILE_LOG(logDEBUG1, ("phase shift: %d (degrees/shift: %d)\n", valShift, val));
int relativePhase = clkPhase[ind] - valShift; int relativePhase = valShift - clkPhase[ind];
FILE_LOG(logDEBUG1, ("relative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind])); FILE_LOG(logDEBUG1, ("relative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind]));
// same phase // same phase
if (!relativePhase) { if (!relativePhase) {
FILE_LOG(logDEBUG1, ("Nothing to do\n")); FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
return; return;
} }
@ -1323,7 +1318,10 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
int getPhase(enum CLKINDEX ind, int degrees) { int getPhase(enum CLKINDEX ind, int degrees) {
if (!degrees) if (!degrees)
return clkPhase[ind]; return clkPhase[ind];
return (clkPhase[ind] * (360.00 / (double)getMaxPhase(ind))); // convert back to degrees
int val = 0;
ConvertToDifferentRange(0, getMaxPhase(ind) - 1, 0, 359, clkPhase[ind], &val);
return val;
} }
int getMaxPhase(enum CLKINDEX ind) { int getMaxPhase(enum CLKINDEX ind) {
@ -1353,14 +1351,10 @@ int validatePhaseinDegrees(enum speedVariable ind, int val, int retval) {
FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", clkIndex)); FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", clkIndex));
int maxShift = getMaxPhase(clkIndex); int maxShift = getMaxPhase(clkIndex);
// convert degrees to shift // convert degrees to shift
double temp = val; int valShift = 0;
temp *= ((double)maxShift / 360.00); ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
if ((temp - (int)temp) > 0.0001) {
temp += 0.5;
}
val = (int)temp;
// convert back to degrees // convert back to degrees
val *= (360.00 / (double)maxShift); ConvertToDifferentRange(0, maxShift - 1, 0, 359, valShift, &val);
if (val == retval) if (val == retval)
return OK; return OK;
@ -1382,7 +1376,7 @@ void configureFrequency(enum CLKINDEX ind, int val) {
// reset phase // reset phase
if (ind == ADC_CLK || ind == DBIT_CLK) { if (ind == ADC_CLK || ind == DBIT_CLK) {
FILE_LOG(logDEBUG1, ("Reseting phase of %s\n", clock_names[ind])); FILE_LOG(logINFO, ("\tReseting phase of %s\n", clock_names[ind]));
configurePhase(ind, 0, 0); configurePhase(ind, 0, 0);
} }
@ -2004,7 +1998,7 @@ void readSample(int ns) {
// loop through all channels // loop through all channels
int ich = 0; int ich = 0;
for (ich = 0; ich < NCHAN_ANALOG; ++ich) { for (ich = 0; ich < NCHAN; ++ich) {
// if channel is in ROI // if channel is in ROI
if ((1 << ich) & ~(adcDisableMask)) { if ((1 << ich) & ~(adcDisableMask)) {

View File

@ -137,7 +137,7 @@ void ALTERA_PLL_ResetPLLAndReconfiguration () {
* @param val value * @param val value
*/ */
void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val) { void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val) {
FILE_LOG(logINFO, ("Setting PLL Reconfig Reg, reg:0x%x, val:0x%x)\n", reg, val)); FILE_LOG(logDEBUG1, ("Setting PLL Reconfig Reg, reg:0x%x, val:0x%x)\n", reg, val));
FILE_LOG(logDEBUG2, ("pllparamreg:0x%x pllcontrolreg:0x%x addrofst:%d addrmsk:0x%x wrmask:0x%x\n", FILE_LOG(logDEBUG2, ("pllparamreg:0x%x pllcontrolreg:0x%x addrofst:%d addrmsk:0x%x wrmask:0x%x\n",
ALTERA_PLL_Param_Reg, ALTERA_PLL_Cntrl_Reg, ALTERA_PLL_Cntrl_AddrOfst, ALTERA_PLL_Cntrl_AddrMask, ALTERA_PLL_Cntrl_WrPrmtrMask)); ALTERA_PLL_Param_Reg, ALTERA_PLL_Cntrl_Reg, ALTERA_PLL_Cntrl_AddrOfst, ALTERA_PLL_Cntrl_AddrMask, ALTERA_PLL_Cntrl_WrPrmtrMask));
@ -198,7 +198,7 @@ void ALTERA_PLL_SetModePolling() {
* @param frequency set * @param frequency set
*/ */
int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) { int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) {
FILE_LOG(logINFO, ("\tC%d: Setting output frequency to %d (pllvcofreq: %dMhz)\n", clkIndex, value, pllVCOFreqMhz)); FILE_LOG(logDEBUG1, ("C%d: Setting output frequency to %d (pllvcofreq: %dMhz)\n", clkIndex, value, pllVCOFreqMhz));
// calculate output frequency // calculate output frequency
float total_div = (float)pllVCOFreqMhz / (float)value; float total_div = (float)pllVCOFreqMhz / (float)value;
@ -225,7 +225,13 @@ int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) {
// write frequency (post-scale output counter C) // write frequency (post-scale output counter C)
ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_C_COUNTER_REG, val); ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_C_COUNTER_REG, val);
return (pllVCOFreqMhz / (low_count + high_count)); /*double temp = ((double)pllVCOFreqMhz / (double)(low_count + high_count));
if ((temp - (int)temp) > 0.0001) {
temp += 0.5;
}
return (int)temp;
*/
return value;
} }

View File

@ -115,7 +115,7 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret);
#endif #endif
// parameters - readout // parameters - readout
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
void setSpeed(enum speedVariable ind, int val, int mode); void setSpeed(enum speedVariable ind, int val, int mode);
int getSpeed(enum speedVariable ind, int mode); int getSpeed(enum speedVariable ind, int mode);
#else #else
@ -283,11 +283,10 @@ int autoCompDisable(int on);
void configureASICTimer(); void configureASICTimer();
void setClockDivider(int val); void setClockDivider(int val);
int getClockDivider(); int getClockDivider();
int setAdcPhase(int st); void setAdcPhase(int val, int degrees);
int getPhase(); int getPhase(int degrees);
void resetPLL(); int getMaxPhaseShift();
u_int32_t setPllReconfigReg(u_int32_t reg, u_int32_t val); int validatePhaseinDegrees(int val, int retval);
void configurePll();
int setThresholdTemperature(int val); int setThresholdTemperature(int val);
int setTemperatureControl(int val); int setTemperatureControl(int val);
int setTemperatureEvent(int val); int setTemperatureEvent(int val);

View File

@ -1957,6 +1957,7 @@ int set_speed(int file_des) {
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
case ADC_PHASE: case ADC_PHASE:
case CLOCK_DIVIDER: case CLOCK_DIVIDER:
case MAX_ADC_PHASE_SHIFT:
#elif CHIPTESTBOARDD #elif CHIPTESTBOARDD
case ADC_PHASE: case ADC_PHASE:
case DBIT_PHASE: case DBIT_PHASE:
@ -1987,7 +1988,7 @@ int set_speed(int file_des) {
modeNotImplemented(speedName, (int)ind); modeNotImplemented(speedName, (int)ind);
break; break;
} }
#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) #if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(JUNGFRAUD))
if (ret == OK && mode == 1) { if (ret == OK && mode == 1) {
ret = FAIL; ret = FAIL;
strcpy(mess, "deg is not defined for this detector.\n"); strcpy(mess, "deg is not defined for this detector.\n");
@ -1998,14 +1999,14 @@ int set_speed(int file_des) {
if (ret == OK) { if (ret == OK) {
// set // set
if ((val != -1) && (Server_VerifyLock() == OK)) { if ((val != -1) && (Server_VerifyLock() == OK)) {
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
setSpeed(ind, val, mode); setSpeed(ind, val, mode);
#else #else
setSpeed(ind, val); setSpeed(ind, val);
#endif #endif
} }
// get // get
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
retval = getSpeed(ind, mode); retval = getSpeed(ind, mode);
#else #else
retval = getSpeed(ind); retval = getSpeed(ind);
@ -2015,9 +2016,13 @@ int set_speed(int file_des) {
char validateName[20] = {0}; char validateName[20] = {0};
sprintf(validateName, "set %s", speedName); sprintf(validateName, "set %s", speedName);
#ifndef GOTTHARDD #ifndef GOTTHARDD
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
if (ind == ADC_PHASE || ind == DBIT_PHASE && mode == 1) { if (ind == ADC_PHASE || ind == DBIT_PHASE && mode == 1) {
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
ret = validatePhaseinDegrees(ind, val, retval); ret = validatePhaseinDegrees(ind, val, retval);
#else
ret = validatePhaseinDegrees(val, retval);
#endif
if (ret == FAIL) { if (ret == FAIL) {
sprintf(mess, "Could not set %s. Set %s, got %s\n", validateName); sprintf(mess, "Could not set %s. Set %s, got %s\n", validateName);
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));

View File

@ -729,7 +729,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i; ++i;
/*! \page config /*! \page config
- <b>adcphase [i] [deg]</b> Sets/gets phase of the ADC clock to i. i is the shift or in degrees if deg is used. deg is optional & only for CTB & Moench. For CTB & Moench, adcphase is reset if adcclk is changed. For Jungfrau, adcphase changed to defaults if clkdivider changed. Jungfrau, CTB & Moench, these are absolute values with limits. Gotthard, relative phase shift. Not for Eiger. \c Returns \c (int) - <b>adcphase [i] [deg]</b> Sets/gets phase of the ADC clock to i. i is the shift or in degrees if deg is used. deg is optional & only for CTB, Moench and Jungfrau. For CTB & Moench, adcphase is reset if adcclk is changed. For Jungfrau, adcphase changed to defaults if clkdivider changed. Jungfrau, CTB & Moench, these are absolute values with limits. Gotthard, relative phase shift. Not for Eiger. \c Returns \c (int)
*/ */
descrToFuncMap[i].m_pFuncName = "adcphase"; descrToFuncMap[i].m_pFuncName = "adcphase";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSpeed; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSpeed;
@ -743,7 +743,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i; ++i;
/*! \page config /*! \page config
- <b>maxadcphaseshift </b> Gets maximum phase shift of the ADC clock. CTB & Moench only. \c Returns \c (int) - <b>maxadcphaseshift </b> Gets maximum phase shift of the ADC clock. CTB, Moench and Jungfrau only. \c Returns \c (int)
*/ */
descrToFuncMap[i].m_pFuncName = "maxadcphaseshift"; descrToFuncMap[i].m_pFuncName = "maxadcphaseshift";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSpeed; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSpeed;
@ -4636,7 +4636,7 @@ std::string slsDetectorCommand::helpSpeed(int action) {
os << "clkdivider c \t sets readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. Not for Gotthard." << std::endl; os << "clkdivider c \t sets readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. Not for Gotthard." << std::endl;
os << "adcclk c \tSets ADC clock frequency in MHz. CTB & Moench only. It also resets adcphase." << std::endl; os << "adcclk c \tSets ADC clock frequency in MHz. CTB & Moench only. It also resets adcphase." << std::endl;
os << "dbitclk c \tSets the clock frequency of the latching of the digital bits in MHz. CTB & Moench only. It also resets dbit phase." << std::endl; os << "dbitclk c \tSets the clock frequency of the latching of the digital bits in MHz. CTB & Moench only. It also resets dbit phase." << std::endl;
os << "adcphase c [deg]\t Sets phase of the ADC clock to i. i is the shift or in degrees if deg is used. deg is optional & only for CTB & Moench. For CTB & Moench, adcphase is reset if adcclk is changed. For Jungfrau, adcphase changed to defaults if clkdivider changed. Jungfrau, CTB & Moench, these are absolute values with limits. Gotthard, relative phase shift. Not for Eiger." << std::endl; os << "adcphase c [deg]\t Sets phase of the ADC clock to i. i is the shift or in degrees if deg is used. deg is optional & only for CTB, Moench & Jungfrau. For CTB & Moench, adcphase is reset if adcclk is changed. For Jungfrau, adcphase changed to defaults if clkdivider changed. Jungfrau, CTB & Moench, these are absolute values with limits. Gotthard, relative phase shift. Not for Eiger." << std::endl;
os << "dbitphase c [deg]\t Sets the phase of the clock for latching of the digital bits to i. i is the shift or in degrees if deg is used. deg is optional. dbitphase is also reset if dbitclk is changed. These are absolute values with limits. for CTB & Moench only." << std::endl; os << "dbitphase c [deg]\t Sets the phase of the clock for latching of the digital bits to i. i is the shift or in degrees if deg is used. deg is optional. dbitphase is also reset if dbitclk is changed. These are absolute values with limits. for CTB & Moench only." << std::endl;
os << "adcpipeline c \t Sets the pipeline of the ADC. For CTB & Moench only." << std::endl; os << "adcpipeline c \t Sets the pipeline of the ADC. For CTB & Moench only." << std::endl;
os << "dbitpipeline c \t Sets the pipeline of the latching of the digital bits. For CTB & Moench only." << std::endl; os << "dbitpipeline c \t Sets the pipeline of the latching of the digital bits. For CTB & Moench only." << std::endl;
@ -4646,11 +4646,11 @@ std::string slsDetectorCommand::helpSpeed(int action) {
os << "clkdivider \t Gets readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. Not for Gotthard." << std::endl; os << "clkdivider \t Gets readout clock divider. EIGER, JUNGFRAU [0(fast speed), 1(half speed), 2(quarter speed)]. Jungfrau, full speed is not implemented and overwrites adcphase to recommended default. Not for Gotthard." << std::endl;
os << "adcclk \tGets ADC clock frequency in MHz. CTB & Moench only. It also resets adcphase." << std::endl; os << "adcclk \tGets ADC clock frequency in MHz. CTB & Moench only. It also resets adcphase." << std::endl;
os << "dbitclk \tGets the clock frequency of the latching of the digital bits in MHz. CTB & Moench only. It also resets dbit phase." << std::endl; os << "dbitclk \tGets the clock frequency of the latching of the digital bits in MHz. CTB & Moench only. It also resets dbit phase." << std::endl;
os << "adcphase [deg]\t Gets phase of the ADC clock. unit is number of shifts or in degrees if deg is used. deg is optional & only for CTB & Moench. For CTB & Moench, adcphase is reset if adcclk is changed. For Jungfrau, adcphase changed to defaults if clkdivider changed. Jungfrau, CTB & Moench, these are absolute values with limits. Gotthard, relative phase shift. Not for Eiger." << std::endl; os << "adcphase [deg]\t Gets phase of the ADC clock. unit is number of shifts or in degrees if deg is used. deg is optional & only for CTB, Moench & Jungfrau. For CTB & Moench, adcphase is reset if adcclk is changed. For Jungfrau, adcphase changed to defaults if clkdivider changed. Jungfrau, CTB & Moench, these are absolute values with limits. Gotthard, relative phase shift. Not for Eiger." << std::endl;
os << "dbitphase [deg]\t Gets the phase of the clock for latching of the digital bits. unit is number of shifts or in degrees if deg is used. deg is optional. dbitphase is also reset if dbitclk is changed. These are absolute values with limits. for CTB & Moench only." << std::endl; os << "dbitphase [deg]\t Gets the phase of the clock for latching of the digital bits. unit is number of shifts or in degrees if deg is used. deg is optional. dbitphase is also reset if dbitclk is changed. These are absolute values with limits. for CTB & Moench only." << std::endl;
os << "adcpipeline \t Gets the pipeline of the ADC. For CTB & Moench only." << std::endl; os << "adcpipeline \t Gets the pipeline of the ADC. For CTB & Moench only." << std::endl;
os << "dbitpipeline \t Gets the pipeline of the latching of the digital bits. For CTB & Moench only." << std::endl; os << "dbitpipeline \t Gets the pipeline of the latching of the digital bits. For CTB & Moench only." << std::endl;
os << "maxadcphaseshift \t Gets maximum phase shift of the ADC clock. CTB & Moench only." << std::endl; os << "maxadcphaseshift \t Gets maximum phase shift of the ADC clock. CTB,Moench and Jungfrau only." << std::endl;
os << "maxdbitphaseshift \t Gets maximum phase shift of the clock for latching of the digital bits. CTB & Moench only." << std::endl; os << "maxdbitphaseshift \t Gets maximum phase shift of the clock for latching of the digital bits. CTB & Moench only." << std::endl;
os << std::endl; os << std::endl;
} }

View File

@ -558,8 +558,6 @@ private:
const int NCHAN_ANALOG = 32; const int NCHAN_ANALOG = 32;
/** Number of digital channels */ /** Number of digital channels */
const int NCHAN_DIGITAL = 4; const int NCHAN_DIGITAL = 4;
/** Number of bytes per pixel */
const int NUM_BYTES_PER_PIXEL = 2;
public: public:
@ -634,11 +632,6 @@ class MoenchData : public GeneralData {
private: private:
/** Number of analog channels */
const int NCHAN_ANALOG = 32;
/** Number of bytes per pixel */
const int NUM_BYTES_PER_PIXEL = 2;
/** Structure of an jungfrau ctb packet header (10G Udp) */ /** Structure of an jungfrau ctb packet header (10G Udp) */
typedef struct { typedef struct {
unsigned char emptyHeader[6]; unsigned char emptyHeader[6];
@ -697,7 +690,7 @@ private:
*/ */
void setImageSize(std::vector<slsDetectorDefs::ROI> r, int s, bool t, void setImageSize(std::vector<slsDetectorDefs::ROI> r, int s, bool t,
slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) { slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) {
int nchans = NCHAN_ANALOG; int nchans = 32;
// if roi // if roi
if (r.size()) { if (r.size()) {
nchans = 0; nchans = 0;