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:
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/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: cd5aea895b07b7af25e3fb74a341a861f9aa291c
Revision: 30
Branch: jungfrau
Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7
Revision: 31
Branch: refactor
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4473
Last Changed Date: 2019-03-26 14:19:40.000000002 +0100 ./slsDetectorFunctionList.c
Last Changed Rev: 4481
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 GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c"
#define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4473
#define GITDATE 0x20190326
#define GITBRANCH "jungfrau"
#define GITREV 0x4481
#define GITDATE 0x20190328
#define GITBRANCH "refactor"

View File

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