jungfrau: special dacs have defined values for settings. getsettings give undefined if different values for special dacs

This commit is contained in:
maliakal_d 2021-07-28 16:44:57 +02:00
commit d9ff946b1d
8 changed files with 78 additions and 21 deletions

View File

@ -370,7 +370,7 @@ class Detector(CppDetectorApi):
Note
----
[Moench] Default is disabled. \n
[Jungfrau] Default is disabled. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (if chipv1.1 and board v2.0).\n
[Jungfrau] Default is disabled. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1).\n
[Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail.
"""
return self.getPowerChip()

View File

@ -387,6 +387,7 @@ void setupDetector() {
for (int i = 0; i < NUM_CLOCKS; ++i) {
clkPhase[i] = 0;
}
chipConfigured = 0;
#ifdef VIRTUAL
sharedMemory_setStatus(IDLE);
#endif
@ -883,21 +884,28 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
if (sett == UNINITIALIZED)
return thisSettings;
int *specialDacValues[] = 0;
const int specialDynamicDacValues[NSPECIALDACS] =
SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
const int specialDynamicHG0DacValues[NSPECIALDACS] =
SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
int specialDacValues[NSPECIALDACS] = {};
// set settings
switch (sett) {
case DYNAMICGAIN:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
LOG(logINFO,
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
specialDacValues = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
memcpy(specialDacValues, specialDynamicDacValues,
NSPECIALDACS * sizeof(int));
break;
case DYNAMICHG0:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL);
LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
bus_r(DAQ_REG)));
specialDacValues = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
memcpy(specialDacValues, specialDynamicHG0DacValues,
NSPECIALDACS * sizeof(int));
break;
/*
case FIXGAIN1:
@ -934,9 +942,10 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
thisSettings = sett;
// set special dacs to defined values
int *specialDacs[] = {SPECIALDACINDEX};
LOG(logINFO, ("Setting spcial dacs\n"));
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
for (int i = 0; i < NSPECIALDACS; ++i) {
setDAC(specialDacs[i], specialDacValues[i], 0);
setDAC(specialDacs[i], specialDacValues[i], 0);
}
// if chip 1.1, and power chip on, configure chip
@ -947,6 +956,41 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
return getSettings();
}
void validateSettings() {
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
int specialDacValues[NUMSETTINGS][NSPECIALDACS] = {
SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS,
SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS};
int settList[NUMSETTINGS] = {DYNAMICGAIN, DYNAMICHG0};
enum detectorSettings sett = UNDEFINED;
for (int isett = 0; isett != NUMSETTINGS; ++isett) {
// dont overwrite if settings is correct
if (sett != UNDEFINED) {
break;
}
// assume it matches current setting in list
sett = settList[isett];
for (int ival = 0; ival < NSPECIALDACS; ++ival) {
// if one value does not match, undefined
if (getDAC(specialDacs[ival], 0) != specialDacValues[isett][ival]) {
sett = UNDEFINED;
break;
}
}
}
// update settings
if (thisSettings != sett) {
LOG(logINFOBLUE,
("Validated settings to %s (%d)\n",
(sett == DYNAMICGAIN
? "dynamicgain"
: (sett == DYNAMICHG0 ? "dynamichg0" : "undefined")),
sett));
thisSettings = sett;
}
}
enum detectorSettings getSettings() {
uint32_t regval = bus_r(DAQ_REG);
@ -988,7 +1032,7 @@ enum detectorSettings getSettings() {
thisSettings = UNDEFINED;
LOG(logERROR, ("Settings read: Undefined. DAQ Reg: 0x%x\n", regval));
}
validateSettings();
return thisSettings;
}
@ -998,11 +1042,10 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
return;
char *dac_names[] = {DAC_NAMES};
LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
val, (mV ? "mV" : "dac units")));
int dacval = val;
#ifdef VIRTUAL
LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind],
val, (mV ? "mV" : "dac units")));
if (!mV) {
dacValues[ind] = val;
}
@ -1011,6 +1054,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
dacValues[ind] = dacval;
}
#else
LOG(logINFO, ("Setting DAC %s\n", dac_names[ind]));
if (LTC2620_SetDACValue((int)ind, val, mV, &dacval) == OK) {
dacValues[ind] = dacval;
if (ind == J_VREF_COMP &&
@ -1023,6 +1067,12 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
}
}
#endif
const int specialDacs[NSPECIALDACS] = SPECIALDACINDEX;
for (int i = 0; i < NSPECIALDACS; ++i) {
if ((int)ind == specialDacs[i]) {
validateSettings();
}
}
}
int getDAC(enum DACINDEX ind, int mV) {
@ -1458,9 +1508,12 @@ int isChipConfigured() {
}
void configureChip() {
LOG(logINFOBLUE, ("Configuring chip\n"));
bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG) & CONFIG_V11_WR_CHIP_CNFG_MSK);
chipConfigured = 1;
// only for chipv1.1
if (chipVersion == 11) {
LOG(logINFOBLUE, ("Configuring chip\n"));
bus_w(CONFIG_V11_REG, bus_r(CONFIG_V11_REG) & CONFIG_V11_WR_CHIP_CNFG_MSK);
chipConfigured = 1;
}
}

View File

@ -3,8 +3,8 @@
#include "sls/sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWRE_VRSN_BOARD2 0x210621 // 1.0 pcb
#define REQRD_FRMWRE_VRSN 0x210622 // 2.0 pcb
#define REQRD_FRMWRE_VRSN_BOARD2 0x210621 // 1.0 pcb (version = 010)
#define REQRD_FRMWRE_VRSN 0x210622 // 2.0 pcb (version = 011)
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
@ -63,10 +63,13 @@ enum DACINDEX {
420 /* J_VREF_COMP */ \
};
#define NUMSETTINGS (2)
#define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS {1000, 500, 400};
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS {1500, 550, 450};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS \
{ 1000, 500, 400 }
#define SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS \
{ 1500, 550, 450 }
enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };

View File

@ -294,7 +294,7 @@ int getAllTrimbits();
#ifndef CHIPTESTBOARDD
enum detectorSettings setSettings(enum detectorSettings sett);
#endif
#ifdef MYTHEN3D
#if defined(MYTHEN3D) || defined(JUNGFRAUD)
void validateSettings();
#endif
enum detectorSettings getSettings();

View File

@ -1687,7 +1687,8 @@ int acquire(int blocking, int file_des) {
// only set
if (Server_VerifyLock() == OK) {
#ifdef JUNGFRAUD
if (!isChipConfigured()) {
// chipv1.1 has to be configured before acquisition
if (getChipVersion() == 11 && !isChipConfigured()) {
ret = FAIL;
strcpy(mess,
"Could not start acquisition. Chip is not configured.\n");

View File

@ -382,7 +382,7 @@ class Detector {
* [Moench] Default is disabled. \n
* [Jungfrau] Default is disabled. Get will return power status. Can be off
* if temperature event occured (temperature over temp_threshold with
* temp_control enabled. Will configure chip (if chipv1.1 and board v2.0)\n [Mythen3][Gotthard2] Default is 1. If module not
* temp_control enabled. Will configure chip (only chip v1.1)\n [Mythen3][Gotthard2] Default is 1. If module not
* connected or wrong module, powerchip will fail.
*/
void setPowerChip(bool on, Positions pos = {});

View File

@ -1314,7 +1314,7 @@ class CmdProxy {
"the chip. \n\t[Moench] Default is 0. \n\t[Jungfrau] Default is 0. Get "
"will return power status. Can be off if temperature event occured "
"(temperature over temp_threshold with temp_control "
"enabled. Will configure chip (if chipv1.1 and board v2.0)\n\t[Mythen3][Gotthard2] Default is 1. If module not "
"enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] Default is 1. If module not "
"connected or wrong module, powerchip will fail.");
INTEGER_COMMAND_VEC_ID(