jungfrau: special settings and configure chip if powered on (1.1 chip)

This commit is contained in:
maliakal_d 2021-07-28 13:34:32 +02:00
parent 41bbe4e3cf
commit f8b14c694d
4 changed files with 45 additions and 13 deletions

View File

@ -883,18 +883,21 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
if (sett == UNINITIALIZED) if (sett == UNINITIALIZED)
return thisSettings; return thisSettings;
int *specialDacValues[] = 0;
// set settings // set settings
switch (sett) { switch (sett) {
case DYNAMICGAIN: case DYNAMICGAIN:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
LOG(logINFO, LOG(logINFO,
("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); ("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG)));
specialDacValues = SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS;
break; break;
case DYNAMICHG0: case DYNAMICHG0:
bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK);
bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL); 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", LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n",
bus_r(DAQ_REG))); bus_r(DAQ_REG)));
specialDacValues = SPECIAL_DEFAULT_DYNAMICHG0_GAIN_VALS;
break; break;
/* /*
case FIXGAIN1: case FIXGAIN1:
@ -930,6 +933,17 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
thisSettings = sett; thisSettings = sett;
// set special dacs to defined values
int *specialDacs[] = {SPECIALDACINDEX};
for (int i = 0; i < NSPECIALDACS; ++i) {
setDAC(specialDacs[i], specialDacValues[i], 0);
}
// if chip 1.1, and power chip on, configure chip
if (getChipVersion() == 11 && powerChip(-1)) {
configureChip();
}
return getSettings(); return getSettings();
} }

View File

@ -65,7 +65,8 @@ enum DACINDEX {
#define NSPECIALDACS (3) #define NSPECIALDACS (3)
#define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP}; #define SPECIALDACINDEX {J_VB_COMP, J_VREF_DS, J_VREF_COMP};
#define SPECIAL_DEFAULT_DYNAMIC_GAIN_VALS {}; #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 NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS }; enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };

View File

@ -1201,8 +1201,7 @@ class CmdProxy {
"verylowgain, g1_hg, g1_lg, g2_hc_hg, g2_hc_lg, " "verylowgain, g1_hg, g1_lg, g2_hc_hg, g2_hc_lg, "
"g2_lc_hg, g2_lc_lg, g4_hg, g4_lg]" "g2_lc_hg, g2_lc_lg, g4_hg, g4_lg]"
"\n\t Detector Settings" "\n\t Detector Settings"
"\n\t[Jungfrau] - [dynamicgain | dynamichg0 | fixgain1 | " "\n\t[Jungfrau] - [dynamicgain | dynamichg0]"
"fixgain2 | forceswitchg1 | forceswitchg2]"
"\n\t[Gotthard] - [dynamicgain | highgain | lowgain | " "\n\t[Gotthard] - [dynamicgain | highgain | lowgain | "
"mediumgain | veryhighgain]" "mediumgain | veryhighgain]"
"\n\t[Gotthard2] - [dynamicgain | fixgain1 | fixgain2]" "\n\t[Gotthard2] - [dynamicgain | fixgain1 | fixgain2]"

View File

@ -142,15 +142,34 @@ TEST_CASE("settings", "[.cmd]") {
Detector det; Detector det;
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
std::vector<std::string> allSett;
allSett.push_back("standard");
allSett.push_back("fast");
allSett.push_back("highgain");
allSett.push_back("dynamicgain");
allSett.push_back("lowgain");
allSett.push_back("mediumgain");
allSett.push_back("veryhighgain");
allSett.push_back("dynamichg0");
allSett.push_back("fixgain1");
allSett.push_back("fixgain2");
allSett.push_back("verylowgain");
allSett.push_back("g1_hg");
allSett.push_back("g1_lg");
allSett.push_back("g2_hc_hg");
allSett.push_back("g2_hc_lg");
allSett.push_back("g2_lc_hg");
allSett.push_back("g2_lc_lg");
allSett.push_back("g4_hg");
allSett.push_back("g4_lg");
allSett.push_back("forceswitchg1");
allSett.push_back("forceswitchg2");
std::vector<std::string> sett; std::vector<std::string> sett;
switch (det_type) { switch (det_type) {
case defs::JUNGFRAU: case defs::JUNGFRAU:
sett.push_back("dynamicgain"); sett.push_back("dynamicgain");
sett.push_back("dynamichg0"); sett.push_back("dynamichg0");
sett.push_back("fixgain1");
sett.push_back("fixgain2");
sett.push_back("forceswitchg1");
sett.push_back("forceswitchg2");
break; break;
case defs::GOTTHARD: case defs::GOTTHARD:
sett.push_back("highgain"); sett.push_back("highgain");
@ -203,10 +222,9 @@ TEST_CASE("settings", "[.cmd]") {
REQUIRE(oss.str() == "settings " + it + "\n"); REQUIRE(oss.str() == "settings " + it + "\n");
} }
} }
for (int i = 0; i != det.size(); ++i) { for (auto &it : allSett) {
if (prev_val[i] != defs::UNDEFINED && if (std::find(sett.begin(), sett.end(), it) == sett.end()) {
prev_val[i] != defs::UNINITIALIZED) { REQUIRE_THROWS(proxy.Call("settings", {it}, -1, PUT));
det.setSettings(prev_val[i], {i});
} }
} }
} }