mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
gotthard2: on chip dacs
This commit is contained in:
parent
a92d931a8f
commit
d7e2ab8ec4
@ -9,6 +9,7 @@ add_executable(gotthard2DetectorServer_virtual
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/LTC2620_Driver.c
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/ASIC_Driver.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -12,7 +12,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
Binary file not shown.
@ -7,6 +7,7 @@
|
||||
#include "LTC2620_Driver.h"
|
||||
#include "common.h"
|
||||
#include "ALTERA_PLL_CYCLONE10.h"
|
||||
#include "ASIC_Driver.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#endif
|
||||
@ -37,6 +38,7 @@ int32_t clkPhase[NUM_CLOCKS] = {0, 0, 0, 0, 0, 0};
|
||||
uint32_t clkFrequency[NUM_CLOCKS] = {0, 0, 0, 0, 0, 0};
|
||||
int highvoltage = 0;
|
||||
int dacValues[NDAC] = {0};
|
||||
int onChipdacValues[ONCHIP_NDAC][NCHIP + 1] = {0};
|
||||
int detPos[2] = {0, 0};
|
||||
|
||||
int isFirmwareCheckDone() {
|
||||
@ -337,13 +339,17 @@ void setupDetector() {
|
||||
|
||||
highvoltage = 0;
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
for (i = 0; i < NUM_CLOCKS; ++i) {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
for (i = 0; i < NDAC; ++i) {
|
||||
dacValues[i] = 0;
|
||||
}
|
||||
for (i = 0; i < ONCHIP_NDAC; ++i) {
|
||||
for (j = 0; j < NCHIP + 1; ++j)
|
||||
onChipdacValues[i][j] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -356,12 +362,15 @@ void setupDetector() {
|
||||
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
|
||||
// dacs
|
||||
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
|
||||
// on chip dacs
|
||||
ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME);
|
||||
#endif
|
||||
|
||||
// Default values
|
||||
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
|
||||
setDefaultDacs();
|
||||
|
||||
setDefaultOnChipDacs();
|
||||
|
||||
// Initialization of acquistion parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||
@ -382,6 +391,20 @@ int setDefaultDacs() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int setDefaultOnChipDacs() {
|
||||
int ret = OK;
|
||||
FILE_LOG(logINFOBLUE, ("Setting Default On chip Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultOnChipVals[ONCHIP_NDAC] = DEFAULT_ONCHIP_DAC_VALS;
|
||||
for(i = 0; i < ONCHIP_NDAC; ++i) {
|
||||
setOnChipDAC((enum ONCHIP_DACINDEX)i, -1, defaultOnChipVals[i]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr){
|
||||
@ -467,6 +490,38 @@ int64_t getNumTriggersLeft() {
|
||||
|
||||
|
||||
/* parameters - dac, hv */
|
||||
int setOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex, int val) {
|
||||
char* names[] = {ONCHIP_DAC_NAMES};
|
||||
FILE_LOG(logDEBUG1, ("Setting on chip dac[%d - %s]: 0x%x\n", (int)ind, names[ind], val));
|
||||
|
||||
if (ind >= ONCHIP_NDAC) {
|
||||
FILE_LOG(logERROR, ("Invalid dac index %d\n", (int)ind));
|
||||
return FAIL;
|
||||
}
|
||||
if (chipIndex >= NCHIP) {
|
||||
FILE_LOG(logERROR, ("Invalid chip index %d\n", chipIndex));
|
||||
return FAIL;
|
||||
}
|
||||
if (val > ONCHIP_DAC_MAX_VAL) {
|
||||
FILE_LOG(logERROR, ("Invalid val %d\n", val));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
char buffer[2];
|
||||
buffer[1] = ((val & 0xF) << 4) | (((int)ind) & 0xF); // LSB (4 bits) + ADDR (4 bits)
|
||||
buffer[0] = (val >> 4) & 0x3F; // MSB (6 bits)
|
||||
|
||||
if (ASIC_Driver_Set(chipIndex, sizeof(buffer), buffer) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
onChipdacValues[ind][chipIndex + 1] = val;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex) {
|
||||
return onChipdacValues[ind][chipIndex + 1];
|
||||
}
|
||||
|
||||
void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0) {
|
||||
return;
|
||||
|
@ -9,12 +9,15 @@
|
||||
#define NCHAN (128)
|
||||
#define NCHIP (10)
|
||||
#define NDAC (16)
|
||||
#define ONCHIP_NDAC (6)
|
||||
#define DYNAMIC_RANGE (16)
|
||||
#define HV_SOFT_MAX_VOLTAGE (200)
|
||||
#define HV_HARD_MAX_VOLTAGE (530)
|
||||
#define HV_DRIVER_FILE_NAME ("/etc/devlinks/hvdac")
|
||||
#define DAC_DRIVER_FILE_NAME ("/etc/devlinks/dac")
|
||||
#define ONCHIP_DAC_DRIVER_FILE_NAME ("/etc/devlinks/chipdac")
|
||||
#define DAC_MAX_MV (2048)
|
||||
#define ONCHIP_DAC_MAX_VAL (0x3FF)
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
@ -37,7 +40,6 @@
|
||||
|
||||
/** Other Definitions */
|
||||
#define BIT16_MASK (0xFFFF)
|
||||
#define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2"
|
||||
|
||||
/* Enums */
|
||||
enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
|
||||
@ -57,6 +59,7 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
|
||||
G2_DAC_UNUSED2, /* 14 */ \
|
||||
G2_VCOM_ADC2 /* 15*/ \
|
||||
};
|
||||
#define DAC_NAMES "vref_h_adc", "dac_unused", "vb_comp_fe", "vb_comp_adc", "vcom_cds", "vref_restore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1", "vref_prech", "vref_l_adc", "vref_cds", "vb_cs", "vb_opa_fd", "dac_unused2", "vcom_adc2"
|
||||
#define DEFAULT_DAC_VALS {2099, /* 0 (1050 mV) VREF_H_ADC*/ \
|
||||
0, /* 1 (0 mV) DAC_UNUSED*/ \
|
||||
0, /* 2 (0 mV) VB_COMP_FE*/ \
|
||||
@ -74,8 +77,27 @@ enum DACINDEX {G2_VREF_H_ADC, /* 0 */ \
|
||||
0, /* 14 (0 mV) DAC_UNUSED2*/ \
|
||||
1400 /* 15 (700 mV) VCOM_ADC2*/ \
|
||||
};
|
||||
|
||||
enum ONCHIP_DACINDEX {G2_VCHIP_COMP_FE, /* 0 */ \
|
||||
G2_VCHIP_OPA_1ST, /* 1 */ \
|
||||
G2_VCHIP_OPA_FD, /* 2 */ \
|
||||
G2_VCHIP_COMP_ADC, /* 3 */ \
|
||||
G2_VCHIP_REF_COMP_FE, /* 4 */ \
|
||||
G2_VCHIP_CS /* 5 */ \
|
||||
};
|
||||
#define ONCHIP_DAC_NAMES "vchip_comp_fe", "vchip_opa_1st", "vchip_opa_fd", "vchip_comp_adc", "vchip_ref_comp_fe", "vchip_cs"
|
||||
|
||||
#define DEFAULT_ONCHIP_DAC_VALS {0x137, /* 0 G2_VCHIP_COMP_FE*/ \
|
||||
0x000, /* 1 G2_VCHIP_OPA_1ST*/ \
|
||||
0x134, /* 2 G2_VCHIP_OPA_FD*/ \
|
||||
0x3FF, /* 3 G2_VCHIP_COMP_ADC*/ \
|
||||
0x100, /* 4 G2_VCHIP_REF_COMP_FE*/ \
|
||||
0x0D0 /* 5 G2_VCHIP_CS*/ \
|
||||
};
|
||||
|
||||
enum CLKINDEX {READOUT_C0, READOUT_C1, SYSTEM_C0, SYSTEM_C1, SYSTEM_C2, SYSTEM_C3, NUM_CLOCKS};
|
||||
#define CLK_NAMES "READOUT_C0", "READOUT_C1", "SYSTEM_C0", "SYSTEM_C1", "SYSTEM_C2", "SYSTEM_C3"
|
||||
|
||||
enum PLLINDEX {READOUT_PLL, SYSTEM_PLL};
|
||||
|
||||
/* Struct Definitions */
|
||||
|
@ -87,6 +87,9 @@ void updateDataBytes();
|
||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D) || GOTTHARD2D
|
||||
int setDefaultDacs();
|
||||
#endif
|
||||
#ifdef GOTTHARD2D
|
||||
int setDefaultOnChipDacs();
|
||||
#endif
|
||||
|
||||
|
||||
// advanced read/write reg
|
||||
@ -242,6 +245,10 @@ extern int AD9257_GetVrefVoltage(int mV); // AD9257.h
|
||||
extern int AD9257_SetVrefVoltage(int val, int mV); // AD9257.h
|
||||
#endif
|
||||
|
||||
#ifdef GOTTHARD2D
|
||||
int setOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex, int val);
|
||||
int getOnChipDAC(enum ONCHIP_DACINDEX ind, int chipIndex);
|
||||
#endif
|
||||
void setDAC(enum DACINDEX ind, int val, int mV);
|
||||
int getDAC(enum DACINDEX ind, int mV);
|
||||
int getMaxDacSteps();
|
||||
|
@ -192,4 +192,6 @@ int get_max_clock_phase_shift(int);
|
||||
int set_clock_divider(int);
|
||||
int get_clock_divider(int);
|
||||
int set_pipeline(int);
|
||||
int get_pipeline(int);
|
||||
int get_pipeline(int);
|
||||
int set_on_chip_dac(int);
|
||||
int get_on_chip_dac(int);
|
@ -15,7 +15,7 @@ int DAC6571_HardMaxVoltage = 0;
|
||||
char DAC6571_DriverFileName[MAX_STR_LENGTH];
|
||||
|
||||
void DAC6571_SetDefines(int hardMaxV, char* driverfname) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring High Voltage\n"));
|
||||
FILE_LOG(logINFOBLUE, ("Configuring High Voltage to %s (hard max: %dV)\n", driverfname, hardMaxV));
|
||||
DAC6571_HardMaxVoltage = hardMaxV;
|
||||
memset(DAC6571_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(DAC6571_DriverFileName, driverfname);
|
||||
|
@ -17,7 +17,7 @@ char LTC2620_D_DriverFileName[MAX_STR_LENGTH];
|
||||
int LTC2620_D_NumDacs = 0;
|
||||
|
||||
void LTC2620_D_SetDefines(int hardMaxV, char* driverfname, int numdacs) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring DACs (LTC2620)\n"));
|
||||
FILE_LOG(logINFOBLUE, ("Configuring DACs (LTC2620) to %s (numdacs:%d, hard max: %dmV)\n", driverfname, numdacs, hardMaxV));
|
||||
LTC2620_D_HardMaxVoltage = hardMaxV;
|
||||
memset(LTC2620_D_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(LTC2620_D_DriverFileName, driverfname);
|
||||
|
@ -294,6 +294,8 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_GET_CLOCK_DIVIDER: return "F_GET_CLOCK_DIVIDER";
|
||||
case F_SET_PIPELINE: return "F_SET_PIPELINE";
|
||||
case F_GET_PIPELINE: return "F_GET_PIPELINE";
|
||||
case F_SET_ON_CHIP_DAC: return "F_SET_ON_CHIP_DAC";
|
||||
case F_GET_ON_CHIP_DAC: return "F_GET_ON_CHIP_DAC";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -465,6 +467,8 @@ void function_table() {
|
||||
flist[F_GET_CLOCK_DIVIDER] = &get_clock_divider;
|
||||
flist[F_SET_PIPELINE] = &set_pipeline;
|
||||
flist[F_GET_PIPELINE] = &get_pipeline;
|
||||
flist[F_SET_ON_CHIP_DAC] = &set_on_chip_dac;
|
||||
flist[F_GET_ON_CHIP_DAC] = &get_on_chip_dac;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -1032,7 +1036,6 @@ int set_dac(int file_des) {
|
||||
serverDacIndex = J_VREF_COMP;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
#ifdef CHIPTESTBOARDD
|
||||
if (ind < NDAC_ONLY) {
|
||||
@ -6007,3 +6010,135 @@ int get_pipeline(int file_des) {
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int set_on_chip_dac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[3] = {-1, -1, -1};
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logDEBUG1, ("Setting On chip dac (%d), chip %d: 0x%x\n", args[0], args[1], args[2]));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
int ind = args[0];
|
||||
int chipIndex = args[1];
|
||||
int val = args[2];
|
||||
enum ONCHIP_DACINDEX dacIndex = 0;
|
||||
switch (ind) {
|
||||
case VB_COMP_FE:
|
||||
dacIndex = G2_VCHIP_COMP_FE;
|
||||
break;
|
||||
case VB_OPA_1ST:
|
||||
dacIndex = G2_VCHIP_OPA_1ST;
|
||||
break;
|
||||
case VB_OPA_FD:
|
||||
dacIndex = G2_VCHIP_OPA_FD;
|
||||
break;
|
||||
case VB_COMP_ADC:
|
||||
dacIndex = G2_VCHIP_COMP_ADC;
|
||||
break;
|
||||
case VREF_COMP_FE:
|
||||
dacIndex = G2_VCHIP_REF_COMP_FE;
|
||||
break;
|
||||
case VB_CS:
|
||||
dacIndex = G2_VCHIP_CS;
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("on chip dac index", ind);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret != FAIL) {
|
||||
char* names[] = {ONCHIP_DAC_NAMES};
|
||||
char modeName[50] = "";
|
||||
sprintf(modeName, "on-chip-dac (%s, %d, chip:%d)", names[dacIndex], (int)dacIndex, chipIndex);
|
||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set %s to %d. Invalid Chip Index. Options[-1, 0 - %d]\n", modeName, val, NCHIP -1);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
} else if (val < 0 || val > ONCHIP_DAC_MAX_VAL ) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set %s to 0x%x. Invalid value. Options:[0 - 0x%x]\n", modeName, val, ONCHIP_DAC_MAX_VAL);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = setOnChipDAC(dacIndex, chipIndex, val);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set %s to 0x%x.\n", modeName, val);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
} else {
|
||||
int retval = getOnChipDAC(dacIndex, chipIndex);
|
||||
FILE_LOG(logDEBUG1, ("retval %s: 0x%x\n", modeName, retval));
|
||||
validate(val, retval, modeName, DEC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
int get_on_chip_dac(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int args[2] = {-1, -1};
|
||||
int retval = -1;
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logDEBUG1, ("Getting On chip dac (%d), chip %d\n", args[0], args[1]));
|
||||
|
||||
#ifndef GOTTHARD2D
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
int ind = args[0];
|
||||
int chipIndex = args[1];
|
||||
enum ONCHIP_DACINDEX dacIndex = 0;
|
||||
switch (ind) {
|
||||
case VB_COMP_FE:
|
||||
dacIndex = G2_VCHIP_COMP_FE;
|
||||
break;
|
||||
case VB_OPA_1ST:
|
||||
dacIndex = G2_VCHIP_OPA_1ST;
|
||||
break;
|
||||
case VB_OPA_FD:
|
||||
dacIndex = G2_VCHIP_OPA_FD;
|
||||
break;
|
||||
case VB_COMP_ADC:
|
||||
dacIndex = G2_VCHIP_COMP_ADC;
|
||||
break;
|
||||
case VREF_COMP_FE:
|
||||
dacIndex = G2_VCHIP_REF_COMP_FE;
|
||||
break;
|
||||
case VB_CS:
|
||||
dacIndex = G2_VCHIP_CS;
|
||||
break;
|
||||
default:
|
||||
modeNotImplemented("on chip dac index", ind);
|
||||
break;
|
||||
}
|
||||
if (ret == OK) {
|
||||
char* names[] = {ONCHIP_DAC_NAMES};
|
||||
char modeName[50] = "";
|
||||
sprintf(modeName, "on-chip-dac (%s, %d, chip:%d)", names[dacIndex], (int)dacIndex, chipIndex);
|
||||
if (chipIndex < -1 || chipIndex >= NCHIP) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not get %s. Invalid Chip Index. Options[-1, 0 - %d]\n", modeName, NCHIP -1);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
} else {
|
||||
retval = getOnChipDAC(dacIndex, chipIndex);
|
||||
FILE_LOG(logDEBUG1, ("retval %s: 0x%x\n", modeName, retval));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
@ -188,7 +188,7 @@
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
/** int with index, */
|
||||
/** int with index */
|
||||
#define INTEGER_IND_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, INDEX, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
std::ostringstream os; \
|
||||
@ -214,6 +214,32 @@
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
/** int with user index */
|
||||
#define INTEGER_USER_IND_COMMAND(CMDNAME, GETFCN, SETFCN, CONV, INDEX, HLPSTR) \
|
||||
std::string CMDNAME(const int action) { \
|
||||
std::ostringstream os; \
|
||||
os << cmd << ' '; \
|
||||
if (action == slsDetectorDefs::HELP_ACTION) \
|
||||
os << HLPSTR << '\n'; \
|
||||
else if (action == slsDetectorDefs::GET_ACTION) { \
|
||||
if (args.size() != 1) { \
|
||||
WrongNumberOfParameters(1); \
|
||||
} \
|
||||
auto t = det->GETFCN(INDEX, std::stoi(args[0]), {det_id}); \
|
||||
os << args [0] << ' ' << OutStringHex(t) << '\n'; \
|
||||
} else if (action == slsDetectorDefs::PUT_ACTION) { \
|
||||
if (args.size() != 2) { \
|
||||
WrongNumberOfParameters(2); \
|
||||
} \
|
||||
auto val = CONV(args[1]); \
|
||||
det->SETFCN(INDEX, std::stoi(args[0]), val, {det_id}); \
|
||||
os << args[0] << ' ' << args[1] << '\n'; \
|
||||
} else { \
|
||||
throw sls::RuntimeError("Unknown action"); \
|
||||
} \
|
||||
return os.str(); \
|
||||
}
|
||||
|
||||
|
||||
/** dac */
|
||||
#define DAC_COMMAND(CMDNAME, GETFCN, SETFCN, DAC_INDEX, HLPSTR) \
|
||||
@ -634,7 +660,14 @@ class CmdProxy {
|
||||
{"dac", &CmdProxy::Dac},
|
||||
{"daclist", &CmdProxy::DacList},
|
||||
{"dacvalues", &CmdProxy::DacValues},
|
||||
|
||||
|
||||
/* on chip dacs */
|
||||
{"vchip_comp_fe", &CmdProxy::vchip_comp_fe},
|
||||
{"vchip_opa_1st", &CmdProxy::vchip_opa_1st},
|
||||
{"vchip_opa_fd", &CmdProxy::vchip_opa_fd},
|
||||
{"vchip_comp_adc", &CmdProxy::vchip_comp_adc},
|
||||
{"vchip_ref_comp_fe", &CmdProxy::vchip_ref_comp_fe},
|
||||
{"vchip_cs", &CmdProxy::vchip_cs},
|
||||
|
||||
/* acquisition */
|
||||
{"clearbusy", &CmdProxy::clearbusy},
|
||||
@ -866,6 +899,7 @@ class CmdProxy {
|
||||
std::string DacList(int action);
|
||||
std::string DacValues(int action);
|
||||
std::vector<std::string> DacCommands();
|
||||
std::string OnChipDac(int action);
|
||||
/* acquisition */
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
/* Receiver Config */
|
||||
@ -1195,6 +1229,27 @@ class CmdProxy {
|
||||
"[dac or mv value][(optional unit) mv] \n\t[Jungfrau] Dac for ??"); //TODO
|
||||
|
||||
|
||||
/* on chip dacs */
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_FE,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for comparator current of analogue front end.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_1st, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_OPA_1ST,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for opa current for driving the other DACs in chip.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_opa_fd, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_OPA_FD,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac current for CDS opa stage.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_comp_adc, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_COMP_ADC,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for comparator current of ADC.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_ref_comp_fe, getOnChipDAC, setOnChipDAC, stoiHex, defs::VREF_COMP_FE,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for reference voltage of the comparator of analogue front end.");
|
||||
|
||||
INTEGER_USER_IND_COMMAND(vchip_cs, getOnChipDAC, setOnChipDAC, stoiHex, defs::VB_CS,
|
||||
"[chip index 0-10, -1 for all][10 bit hex value] \n\t[Gotthard2] On chip Dac for current injection into preamplifier.");
|
||||
|
||||
|
||||
|
||||
/* acquisition */
|
||||
|
||||
EXECUTE_SET_COMMAND_NOID(clearbusy, clearAcquiringFlag,
|
||||
|
@ -235,6 +235,12 @@ class Detector {
|
||||
|
||||
void setDAC(defs::dacIndex index, int value, bool mV, Positions pos = {});
|
||||
|
||||
/* [Gotthard2] */
|
||||
Result<int> getOnChipDAC(defs::dacIndex index, int chipIndex, Positions pos = {}) const;
|
||||
|
||||
/* [Gotthard2] */
|
||||
void setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos = {});
|
||||
|
||||
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
|
||||
|
||||
/**
|
||||
|
@ -632,6 +632,12 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int setDAC(int val, dacIndex index, int mV);
|
||||
|
||||
/* [Gotthard2] */
|
||||
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex);
|
||||
|
||||
/* [Gotthard2] */
|
||||
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value);
|
||||
|
||||
/**
|
||||
* Get adc value
|
||||
* @param index adc(DAC) index
|
||||
|
@ -285,6 +285,14 @@ void Detector::setDAC(defs::dacIndex index, int value, bool mV, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setDAC, pos, value, index, mV);
|
||||
}
|
||||
|
||||
Result<int> Detector::getOnChipDAC(defs::dacIndex index, int chipIndex, Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getOnChipDAC, pos, index, chipIndex);
|
||||
}
|
||||
|
||||
void Detector::setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setOnChipDAC, pos, index, chipIndex, value);
|
||||
}
|
||||
|
||||
Result<defs::timingMode> Detector::getTimingMode(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimingMode, pos,
|
||||
defs::GET_TIMING_MODE);
|
||||
|
@ -1510,6 +1510,20 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex) {
|
||||
int args[]{static_cast<int>(index), chipIndex};
|
||||
int retval = -1;
|
||||
sendToDetector(F_GET_ON_CHIP_DAC, args, retval);
|
||||
FILE_LOG(logDEBUG1) << "On chip DAC " << index << " (chip index:" << chipIndex << "): " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value) {
|
||||
int args[]{static_cast<int>(index), chipIndex, value};
|
||||
FILE_LOG(logDEBUG1) << "Setting On chip DAC " << index << " (chip index:" << chipIndex << ") to " << value;
|
||||
sendToDetector(F_SET_ON_CHIP_DAC, args, nullptr);
|
||||
}
|
||||
|
||||
int slsDetector::getADC(dacIndex index) {
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting ADC " << index;
|
||||
|
@ -9,6 +9,110 @@
|
||||
auto GET = slsDetectorDefs::GET_ACTION;
|
||||
auto PUT = slsDetectorDefs::PUT_ACTION;
|
||||
|
||||
TEST_CASE("vchip", "[.cmd]") {
|
||||
int prev_val = 0;
|
||||
|
||||
if (test::type == slsDetectorDefs::GOTTHARD2) {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_fe", GET)); // needs a chip index
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_fe -1 0x400", GET)); // max val is 0x3ff
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_comp_fe -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_comp_fe -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_fe -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_1st", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_opa_1st -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_opa_1st -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_1st -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_fd", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_opa_fd -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_opa_fd -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_opa_fd -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_adc", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_comp_adc -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_comp_adc -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_comp_adc -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_ref_comp_fe", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_ref_comp_fe -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_ref_comp_fe -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_ref_comp_fe -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_cs", GET)); // needs a chip index
|
||||
{
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1", GET, nullptr, oss));
|
||||
std::string s = (oss.str()).erase (0, strlen("vchip_cs -1 "));
|
||||
prev_val = stoul(s, 0, 16);
|
||||
}
|
||||
{
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1 0x137", PUT));
|
||||
std::ostringstream oss;
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1", GET, nullptr, oss));
|
||||
REQUIRE(oss.str() == "vchip_cs -1 0x137\n");
|
||||
}
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("vchip_cs -1 " + sls::ToStringHex(prev_val), PUT));
|
||||
} else {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_fe", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_1st", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_opa_fd", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_comp_adc", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_ref_comp_fe", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("vchip_cs", GET));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST_CASE("dacs", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("daclist", GET));
|
||||
|
@ -175,6 +175,8 @@ enum detFuncs{
|
||||
F_GET_CLOCK_DIVIDER,
|
||||
F_SET_PIPELINE,
|
||||
F_GET_PIPELINE,
|
||||
F_SET_ON_CHIP_DAC,
|
||||
F_GET_ON_CHIP_DAC,
|
||||
NUM_DET_FUNCTIONS,
|
||||
|
||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */
|
||||
@ -414,6 +416,9 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_CLOCK_DIVIDER: return "F_GET_CLOCK_DIVIDER";
|
||||
case F_SET_PIPELINE: return "F_SET_PIPELINE";
|
||||
case F_GET_PIPELINE: return "F_GET_PIPELINE";
|
||||
case F_SET_ON_CHIP_DAC: return "F_SET_ON_CHIP_DAC";
|
||||
case F_GET_ON_CHIP_DAC: return "F_GET_ON_CHIP_DAC";
|
||||
|
||||
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define APIMOENCH 0x190820
|
||||
#define APIGOTTHARD 0x191106
|
||||
#define APICTB 0x191106
|
||||
#define APIGOTTHARD2 0x191106
|
||||
#define APIJUNGFRAU 0x191106
|
||||
#define APIEIGER 0x191106
|
||||
#define APIMYTHEN3 0x191107
|
||||
#define APIGOTTHARD2 0x191108
|
||||
|
Loading…
x
Reference in New Issue
Block a user