mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 16:27:13 +02:00
ctb & moench: phase fix for absolute within limits, option to set as degrees and get max phase shift, bug fix for eiger with implementation of 2 udp interface
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repsitory UUID: 7cd5bc8b2db6e89fbec4c06c65e683cf788338c0
|
||||
Revision: 46
|
||||
Branch: jungfrau
|
||||
Repsitory UUID: c7ad548e4c2026a826b9f269f32d9970ce0a44e8
|
||||
Revision: 48
|
||||
Branch: refactor
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 4474
|
||||
Last Changed Date: 2019-03-26 15:01:04.000000002 +0100 ./slsDetectorServer_defs.h
|
||||
Last Changed Rev: 4478
|
||||
Last Changed Date: 2019-03-27 11:13:21.000000002 +0100 ../slsDetectorServer/slsDetectorServer_funcs.c
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "7cd5bc8b2db6e89fbec4c06c65e683cf788338c0"
|
||||
#define GITREPUUID "c7ad548e4c2026a826b9f269f32d9970ce0a44e8"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x4474
|
||||
#define GITDATE 0x20190326
|
||||
#define GITBRANCH "jungfrau"
|
||||
#define GITREV 0x4478
|
||||
#define GITDATE 0x20190327
|
||||
#define GITBRANCH "refactor"
|
||||
|
@ -781,16 +781,15 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret) {
|
||||
|
||||
/* parameters - speed, readout */
|
||||
|
||||
void setSpeed(enum speedVariable ind, int val) {
|
||||
void setSpeed(enum speedVariable ind, int val, int mode) {
|
||||
switch(ind) {
|
||||
case ADC_PHASE:
|
||||
case PHASE_SHIFT:
|
||||
FILE_LOG(logINFOBLUE, ("Configuring ADC Phase\n"));
|
||||
configurePhase(ADC_CLK, val);
|
||||
configurePhase(ADC_CLK, val, mode);
|
||||
break;
|
||||
case DBIT_PHASE:
|
||||
FILE_LOG(logINFOBLUE, ("Configuring Dbit Phase\n"));
|
||||
configurePhase(DBIT_CLK, val);
|
||||
configurePhase(DBIT_CLK, val, mode);
|
||||
break;
|
||||
case ADC_CLOCK:
|
||||
FILE_LOG(logINFOBLUE, ("Configuring ADC Clock\n"));
|
||||
@ -818,23 +817,26 @@ void setSpeed(enum speedVariable ind, int val) {
|
||||
}
|
||||
}
|
||||
|
||||
int getSpeed(enum speedVariable ind) {
|
||||
int getSpeed(enum speedVariable ind, int mode) {
|
||||
switch(ind) {
|
||||
case ADC_PHASE:
|
||||
case PHASE_SHIFT:
|
||||
return getPhase(ADC_CLK);
|
||||
return getPhase(ADC_CLK, mode);
|
||||
case DBIT_PHASE:
|
||||
return getPhase(DBIT_CLK);
|
||||
return getPhase(DBIT_CLK, mode);
|
||||
case MAX_ADC_PHASE_SHIFT:
|
||||
return getMaxPhase(ADC_CLK);
|
||||
case MAX_DBIT_PHASE_SHIFT:
|
||||
return getMaxPhase(DBIT_CLK);
|
||||
case ADC_CLOCK:
|
||||
return getFrequency(ADC_CLK);
|
||||
case DBIT_CLOCK:
|
||||
return getFrequency(DBIT_CLK);
|
||||
case CLOCK_DIVIDER:
|
||||
return getFrequency(RUN_CLK);
|
||||
case ADC_PIPELINE:
|
||||
return getAdcOffsetRegister(1);
|
||||
case DBIT_PIPELINE:
|
||||
return getAdcOffsetRegister(0);
|
||||
case CLOCK_DIVIDER:
|
||||
return getFrequency(RUN_CLK);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@ -1633,41 +1635,100 @@ int enableTenGigabitEthernet(int val) {
|
||||
|
||||
|
||||
// ind can only be ADC_CLK or DBIT_CLK
|
||||
void configurePhase(enum CLKINDEX ind, int val) {
|
||||
char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
|
||||
if (val > 65535 || val < -65535) {
|
||||
FILE_LOG(logERROR, ("\tPhase provided for C%d(%s) outside limits\n", ind, clock_names[ind]));
|
||||
return;
|
||||
}
|
||||
int relativePhase = clkPhase[ind] - val;
|
||||
void configurePhase(enum CLKINDEX ind, int val, int degrees) {
|
||||
char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
|
||||
int maxShift = getMaxPhase(ind);
|
||||
|
||||
// validation
|
||||
if (degrees && (val < 0 || val > 359)) {
|
||||
FILE_LOG(logERROR, ("\tPhase provided for C%d(%s) outside limits (0 - 359°C)\n", ind, clock_names[ind]));
|
||||
return;
|
||||
}
|
||||
if (!degrees && (val < 0 || val > maxShift - 1)) {
|
||||
FILE_LOG(logERROR, ("\tPhase provided for C%d(%s) outside limits (0 - %d phase shifts)\n", ind, clock_names[ind], maxShift - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Configuring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
|
||||
int valShift = val;
|
||||
// convert to phase shift
|
||||
if (degrees) {
|
||||
double temp = val * ((double)maxShift / 360.00);
|
||||
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));
|
||||
|
||||
int relativePhase = clkPhase[ind] - valShift;
|
||||
FILE_LOG(logDEBUG1, ("relative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind]));
|
||||
|
||||
// same phase
|
||||
if (!relativePhase) {
|
||||
FILE_LOG(logDEBUG1, ("Nothing to do\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Configuring Phase of C%d(%s) to %d\n", ind, clock_names[ind], val));
|
||||
|
||||
int phase = 0;
|
||||
int maxShifts = (PLL_VCO_FREQ_MHZ / clkDivider[ind]) * MAX_PHASE_SHIFTS_STEPS;
|
||||
FILE_LOG(logDEBUG1, ("Clock: %d MHz, VCO:%d MHz, Max Phase shifts:%d\n",
|
||||
clkDivider[ind], PLL_VCO_FREQ_MHZ, maxShifts));
|
||||
|
||||
// delay clk
|
||||
if (relativePhase > 0) {
|
||||
phase = (maxShifts - relativePhase);
|
||||
phase = (maxShift - relativePhase);
|
||||
} else {
|
||||
phase = (-1) * relativePhase;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tphase out %d (0x%08x)\n", phase, phase));
|
||||
FILE_LOG(logDEBUG1, ("[Single Direction] Phase:%d (0x%x). Max Phase shifts:%d\n", phase, phase, maxShift));
|
||||
|
||||
ALTERA_PLL_SetPhaseShift(phase, (int)ind, 0);
|
||||
|
||||
clkPhase[ind] = val;
|
||||
clkPhase[ind] = valShift;
|
||||
}
|
||||
|
||||
int getPhase(enum CLKINDEX ind) {
|
||||
return clkPhase[ind];
|
||||
int getPhase(enum CLKINDEX ind, int degrees) {
|
||||
if (!degrees)
|
||||
return clkPhase[ind];
|
||||
return (clkPhase[ind] * (360.00 / (double)getMaxPhase(ind)));
|
||||
}
|
||||
|
||||
int getMaxPhase(enum CLKINDEX ind) {
|
||||
int ret = ((double)PLL_VCO_FREQ_MHZ / (double)clkDivider[ind]) * MAX_PHASE_SHIFTS_STEPS;
|
||||
|
||||
char clock_names[4][10]={"run_clk","adc_clk", "sync_clk", "dbit_clk"};
|
||||
FILE_LOG(logDEBUG1, ("Max Phase Shift (%s): %d (Clock: %d MHz, VCO:%d MHz)\n",
|
||||
clock_names[ind], ret, clkDivider[ind], PLL_VCO_FREQ_MHZ));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int validatePhaseinDegrees(enum speedVariable ind, int val, int retval) {
|
||||
if (val == -1)
|
||||
return OK;
|
||||
enum CLKINDEX clkIndex;
|
||||
switch(ind) {
|
||||
case ADC_PHASE:
|
||||
clkIndex = ADC_CLK;
|
||||
break;
|
||||
case DBIT_PHASE:
|
||||
clkIndex = DBIT_CLK;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown speed enum %d for validating phase in degrees\n", (int)ind));
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", clkIndex));
|
||||
int maxShift = getMaxPhase(clkIndex);
|
||||
// convert degrees to shift
|
||||
double temp = val;
|
||||
temp *= ((double)maxShift / 360.00);
|
||||
if ((temp - (int)temp) > 0.0001) {
|
||||
temp += 0.5;
|
||||
}
|
||||
val = (int)temp;
|
||||
// convert back to degrees
|
||||
val *= (360.00 / (double)maxShift);
|
||||
|
||||
if (val == retval)
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
void configureFrequency(enum CLKINDEX ind, int val) {
|
||||
|
Reference in New Issue
Block a user