This commit is contained in:
maliakal_d 2019-10-08 10:57:07 +02:00
parent 7a66dd08a3
commit 030cfacc9b
10 changed files with 310 additions and 25 deletions

View File

@ -1967,7 +1967,7 @@ int setPatternWaitAddress(int level, int addr) {
}
// get
uint32_t regval = bus_r((reg & mask) >> offset);
uint32_t regval = ((bus_r(reg) & mask) >> offset);
FILE_LOG(logDEBUG1, (" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
return regval;
}

View File

@ -7,6 +7,7 @@ add_executable(gotthard2DetectorServer_virtual
../slsDetectorServer/src/communication_funcs_UDP.c
../slsDetectorServer/src/DAC6571.c
../slsDetectorServer/src/common.c
../slsDetectorServer/src/LTC2620_Driver.c
)
include_directories(

View File

@ -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
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
OBJS = $(SRCS:.c=.o)

View File

@ -4,6 +4,7 @@
#include "clogger.h"
#include "nios.h"
#include "DAC6571.h"
#include "LTC2620_Driver.h"
#include "common.h"
#ifdef VIRTUAL
#include "communication_funcs_UDP.h"
@ -36,6 +37,7 @@ int virtual_stop = 0;
uint32_t clkDivider[NUM_CLOCKS] = {125, 20, 80};
int highvoltage = 0;
int dacValues[NDAC] = {0};
int detPos[2] = {0, 0};
int isFirmwareCheckDone() {
@ -82,6 +84,7 @@ void basictests() {
return;
}
uint16_t hversion = getHardwareVersionNumber();
uint32_t ipadd = getDetectorIP();
uint64_t macadd = getDetectorMAC();
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
@ -91,6 +94,8 @@ void basictests() {
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
FILE_LOG(logINFOBLUE, ("************ Gotthard2 Server *********************\n"
"Hardware Version:\t\t 0x%x\n"
"Detector IP Addr:\t\t 0x%x\n"
"Detector MAC Addr:\t\t 0x%llx\n\n"
@ -100,6 +105,7 @@ void basictests() {
"Required Firmware Version:\t 0x%x\n"
"Client-Software API Version:\t 0x%llx\n"
"********************************************************\n",
hversion,
ipadd,
(long long unsigned int)macadd,
(long long int)fwversion,
@ -248,6 +254,13 @@ u_int64_t getFirmwareAPIVersion() {
return ((bus_r(API_VERSION_REG) & API_VERSION_MSK) >> API_VERSION_OFST);
}
u_int16_t getHardwareVersionNumber() {
#ifdef VIRTUAL
return 0;
#endif
return ((bus_r(MCB_SERIAL_NO_REG)));// & HARDWARE_VERSION_NUM_MSK) >> HARDWARE_VERSION_NUM_OFST);
}
u_int32_t getDetectorNumber(){
#ifdef VIRTUAL
return 0;
@ -329,20 +342,45 @@ void setupDetector() {
clkDivider[TICK_CLK] = DEFAULT_TICK_CLK;
clkDivider[SAMPLING_CLK] = DEFAULT_SAMPLING_CLK;
highvoltage = 0;
{
int i;
for (i = 0; i < NDAC; ++i) {
dacValues[i] = 0;
}
}
// hv
#ifndef VIRTUAL
// hv
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
// dacs
LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC);
#endif
// Default values
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
setDefaultDacs();
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
setTimer(ACQUISITION_TIME, DEFAULT_EXPTIME);
setTimer(ACQUISITION_TIME, DEFAULT_PERIOD);
}
int setDefaultDacs() {
int ret = OK;
FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n"));
{
int i = 0;
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
for(i = 0; i < NDAC; ++i) {
// if not already default, set it to default
if (dacValues[i] != defaultvals[i]) {
setDAC((enum DACINDEX)i,defaultvals[i],0);
}
}
}
return ret;
}
/* set parameters - dr, roi */
@ -451,6 +489,46 @@ int64_t getTimeLeft(enum timerIndex ind){
/* parameters - dac, hv */
void setDAC(enum DACINDEX ind, int val, int mV) {
if (val < 0)
return;
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
int dacval = val;
#ifdef VIRTUAL
if (!mV) {
dacValues[ind] = val;
}
// convert to dac units
else if (LTC2620_D_VoltageToDac(val, &dacval) == OK) {
dacValues[ind] = dacval;
}
#else
if (LTC2620_D_SetDACValue((int)ind, val, mV, &dacval) == OK) {
dacValues[ind] = dacval;
}
#endif
}
int getDAC(enum DACINDEX ind, int mV) {
if (!mV) {
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, dacValues[ind]));
return dacValues[ind];
}
int voltage = -1;
LTC2620_D_DacToVoltage(dacValues[ind], &voltage);
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, dacValues[ind], voltage));
return voltage;
}
int getMaxDacSteps() {
return LTC2620_D_GetMaxNumSteps();
}
int setHighVoltage(int val){
if (val > HV_SOFT_MAX_VOLTAGE) {
val = HV_SOFT_MAX_VOLTAGE;

View File

@ -14,6 +14,8 @@
#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 DAC_MAX_MV (2048)
/** Default Parameters */
#define DEFAULT_NUM_FRAMES (1)
@ -34,7 +36,40 @@
#define BIT16_MASK (0xFFFF)
/* Enums */
enum DACINDEX {DAC0};
enum DACINDEX {G_VREF_H_ADC, /* 0 */ \
G_DAC_UNUSED, /* 1 */ \
G_VB_COMP_FE, /* 2 */ \
G_VB_COMP_ADC, /* 3 */ \
G_VCOM_CDS, /* 4 */ \
G_VREF_RESTORE,/* 5 */ \
G_VB_OPA_1ST, /* 6 */ \
G_VREF_COMP_FE,/* 7 */ \
G_VCOM_ADC1, /* 8 */ \
G_VREF_PRECH, /* 9 */ \
G_VREF_L_ADC, /* 10 */ \
G_VREF_CDS, /* 11 */ \
G_VB_CS, /* 12 */ \
G_VB_OPA_FD, /* 13 */ \
G_DAC_UNUSED2, /* 14 */ \
G_VCOM_ADC2 /* 15*/ \
};
#define DEFAULT_DAC_VALS {1723, /* 0 (1050 mV) VREF_H_ADC*/ \
0, /* 1 (0 mV) DAC_UNUSED*/ \
0, /* 2 (0 mV) VB_COMP_FE*/ \
0, /* 3 (0 mV) VB_COMP_ADC*/ \
560, /* 4 (700 mV) VCOM_CDS*/ \
250, /* 5 (320 mV) VREF_RESTORE*/ \
0, /* 6 (0 mV) VB_OPA_1ST*/ \
0, /* 7 (0 mV) VREF_COMP_FE*/ \
560, /* 8 (700 mV) VCOM_ADC1*/ \
700, /* 9 (860 mV) VREF_PRECH*/ \
576, /* 10 (350 mV) VREF_L_ADC*/ \
470, /* 11 (600 mV) VREF_CDS*/ \
2000, /* 12 (1400 mV) VB_CS*/ \
0, /* 13 (0 mV) VB_OPA_FD*/ \
0, /* 14 (0 mV) DAC_UNUSED2*/ \
560 /* 15 (700 mV) VCOM_ADC2*/ \
};
enum CLKINDEX {RUN_CLK, TICK_CLK, SAMPLING_CLK, NUM_CLOCKS};
/* Struct Definitions */

View File

@ -51,7 +51,7 @@ int detectorTest(enum digitalTestMode arg);
int64_t getDetectorId(enum idMode arg);
u_int64_t getFirmwareVersion();
u_int64_t getFirmwareAPIVersion();
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D)
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
u_int16_t getHardwareVersionNumber();
#endif
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
@ -85,7 +85,7 @@ int allocateRAM();
void updateDataBytes();
#endif
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D)
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MYTHEN3D) || GOTTHARD2D
int setDefaultDacs();
#endif
@ -212,11 +212,9 @@ extern int AD9257_GetVrefVoltage(int mV); // AD9257.h
extern int AD9257_SetVrefVoltage(int val, int mV); // AD9257.h
#endif
#if (!defined(GOTTHARD2D))
void setDAC(enum DACINDEX ind, int val, int mV);
int getDAC(enum DACINDEX ind, int mV);
int getMaxDacSteps();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD)
int dacToVoltage(int dac);
int checkVLimitCompliant(int mV);

View File

@ -841,14 +841,11 @@ int set_dac(int file_des) {
case HIGH_VOLTAGE:
case V_LIMIT:
break;
#elif GOTTHARD2D
case HIGH_VOLTAGE:
break;
#elif MYTHEN3D
case HIGH_VOLTAGE:
break;
case M_casSh: // in sls_detector_defs.h
serverDacIndex = CASSH; // in mythen3 slsDetectorServer_defs.h
case M_casSh:
serverDacIndex = CASSH;
break;
case M_Vth2:
serverDacIndex = VTH2;
@ -895,8 +892,51 @@ int set_dac(int file_des) {
case M_VdcSh:
serverDacIndex = VDCSH;
break;
#elif GOTTHARD2D
case HIGH_VOLTAGE:
break;
case VREF_H_ADC:
serverDacIndex = G_VREF_H_ADC;
break;
case VB_COMP_FE:
serverDacIndex = G_VB_COMP_FE;
break;
case VB_COMP_ADC:
serverDacIndex = G_VB_COMP_ADC;
break;
case VCOM_CDS:
serverDacIndex = G_VCOM_CDS;
break;
case VREF_RESTORE:
serverDacIndex = G_VREF_RESTORE;
break;
case VB_OPA_1ST:
serverDacIndex = G_VB_OPA_1ST;
break;
case VREF_COMP_FE:
serverDacIndex = G_VREF_COMP_FE;
break;
case VCOM_ADC1:
serverDacIndex = G_VCOM_ADC1;
break;
case VREF_PRECH:
serverDacIndex = G_VREF_PRECH;
break;
case VREF_L_ADC:
serverDacIndex = G_VREF_L_ADC;
break;
case VREF_CDS:
serverDacIndex = G_VREF_CDS;
break;
case VB_CS:
serverDacIndex = G_VB_CS;
break;
case VB_OPA_FD:
serverDacIndex = G_VB_OPA_FD;
break;
case VCOM_ADC2:
serverDacIndex = G_VCOM_ADC2;
break;
#endif
default:
#ifdef JUNGFRAUD
@ -1063,11 +1103,6 @@ int set_dac(int file_des) {
validate(val, retval, "set vlimit", DEC);
break;
#endif
#ifdef GOTTHARD2D
default:
break;
#else
// dacs
default:
if (mV && val > DAC_MAX_MV) {
@ -1123,7 +1158,6 @@ int set_dac(int file_des) {
}
FILE_LOG(logDEBUG1, ("Dac (%d): %d %s\n\n", serverDacIndex, retval, (mV ? "mV" : "dac units")));
break;
#endif
}
}
}

View File

@ -1333,6 +1333,105 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vref_h_adc</b> Sets/gets dac for reference voltage high of ADC for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vref_h_adc";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vb_comp_fe</b> Sets/gets dac for comparator current of analogue front end for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vb_comp_fe";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vb_comp_adc</b> Sets/gets dac for comparator current of ADC for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vb_comp_adc";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vcom_cds</b> Sets/gets dac for common mode voltage of CDS stage for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vcom_cds";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vref_restore</b> Sets/gets dac for reference charging voltage of temparory storage cell in high gain for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vref_restore";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vb_opa_1st</b> Sets/gets dac for opa current for driving the other DACs in chip for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vb_opa_1st";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vref_comp_fe</b> Sets/gets dac for reference voltage of the comparator of analogue front end for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vref_comp_fe";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vcom_adc1</b> Sets/gets dac for common mode voltage of ADC DAC bank 1 for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vcom_adc1";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vref_prech</b> Sets/gets dac for reference votlage for precharing the preamplifier for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vref_prech";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vref_l_adc</b> Sets/gets dac for reference voltage low for ADC for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vref_l_adc";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vref_cds</b> Sets/gets dac for reference voltage of CDS applied to the temporary storage cell in medium and low gain for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vref_cds";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vb_cs</b> Sets/gets dac for current injection into preamplifier for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vb_cs";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vb_opa_fd</b> Sets/gets dac for current for CDS opa stage for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vb_opa_fd";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vcom_adc2</b> Sets/gets dac for common mode voltage of ADC DAC bank 2 for Gotthard2. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
descrToFuncMap[i].m_pFuncName = "vcom_adc2";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;
++i;
/* r/w timers */
/*! \page settings
\section settingsadcs ADCs
@ -3424,8 +3523,34 @@ std::string slsDetectorCommand::cmdDAC(int narg, const char * const args[], int
dac = M_cas;
else if (cmd == "vicin")
dac = M_vIcin;
else if (cmd == "vipreout")
dac = M_vIpreOut;
else if (cmd == "vref_h_adc")
dac = VREF_H_ADC;
else if (cmd == "vb_comp_fe")
dac = VB_COMP_FE;
else if (cmd == "vb_comp_adc")
dac = VB_COMP_ADC;
else if (cmd == "vcom_cds")
dac = VCOM_CDS;
else if (cmd == "vref_restore")
dac = VREF_RESTORE;
else if (cmd == "vb_opa_1st")
dac = VB_OPA_1ST;
else if (cmd == "vref_comp_fe")
dac = VREF_COMP_FE;
else if (cmd == "vcom_adc1")
dac = VCOM_ADC1;
else if (cmd == "vref_prech")
dac = VREF_PRECH;
else if (cmd == "vref_l_adc")
dac = VREF_L_ADC;
else if (cmd == "vref_cds")
dac = VREF_CDS;
else if (cmd == "vb_cs")
dac = VB_CS;
else if (cmd == "vb_opa_fd")
dac = VB_OPA_FD;
else if (cmd == "vcom_adc2")
dac = VCOM_ADC2;
else
return std::string("cannot decode dac ") + cmd;

View File

@ -437,6 +437,20 @@ format
M_cas, /**< mythen 3 >*/
M_vIcin, /**< mythen 3 >*/
M_vIpreOut, /**< mythen 3 >*/
VREF_H_ADC, /**< gotthard 2 >*/
VB_COMP_FE, /**< gotthard 2 >*/
VB_COMP_ADC, /**< gotthard 2 >*/
VCOM_CDS, /**< gotthard 2 >*/
VREF_RESTORE, /**< gotthard 2 >*/
VB_OPA_1ST, /**< gotthard 2 >*/
VREF_COMP_FE, /**< gotthard 2 >*/
VCOM_ADC1, /**< gotthard 2 >*/
VREF_PRECH, /**< gotthard 2 >*/
VREF_L_ADC, /**< gotthard 2 >*/
VREF_CDS, /**< gotthard 2 >*/
VB_CS, /**< gotthard 2 >*/
VB_OPA_FD, /**< gotthard 2 >*/
VCOM_ADC2, /**< gotthard 2 >*/
V_POWER_A = 100, /**new chiptest board */
V_POWER_B = 101, /**new chiptest board */
V_POWER_C = 102, /**new chiptest board */
@ -1195,7 +1209,7 @@ struct detParameters {
nChanY = 1;
nChipX = 10;
nChipY = 1;
nDacs = 16;
nDacs = 14;
dynamicRange = 16;
nGappixelsX = 0;
nGappixelsY = 0;

View File

@ -9,4 +9,4 @@
#define APIJUNGFRAU 0x190930
#define APIEIGER 0x190930
#define APIMYTHEN3 0x191004
#define APIGOTTHARD2 0x191001
#define APIGOTTHARD2 0x191008