gotthard2:hv

This commit is contained in:
2019-09-02 12:57:24 +02:00
parent 4a112104ad
commit bd95126da2
9 changed files with 54 additions and 9 deletions

View File

@ -4,7 +4,8 @@ add_executable(gotthard2DetectorServer_virtual
../slsDetectorServer/src/slsDetectorServer_funcs.c
../slsDetectorServer/src/communication_funcs.c
../slsDetectorServer/src/blackfin.c
../slsDetectorServer/src/communication_funcs_UDP.c
../slsDetectorServer/src/communication_funcs_UDP.c
../slsDetectorServer/src/DAC6571.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
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
OBJS = $(SRCS:.c=.o)

View File

@ -2,6 +2,8 @@
#include "versionAPI.h"
#include "clogger.h"
#include "blackfin.h"
#include "DAC6571.h"
#include "common.h"
#ifdef VIRTUAL
#include "communication_funcs_UDP.h"
#endif
@ -29,6 +31,7 @@ int virtual_status = 0;
int virtual_stop = 0;
#endif
int highvoltage = 0;
int isFirmwareCheckDone() {
@ -57,6 +60,8 @@ void basictests() {
firmware_check_done = 1;
return;
#else
// faking it
firmware_check_done = 1;
#endif
@ -173,6 +178,10 @@ void initStopServer() {
void setupDetector() {
FILE_LOG(logINFO, ("This Server is for 1 Gotthard2 module \n"));
// hv
DAC6571_SetDefines(HV_SOFT_MAX_VOLTAGE, HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
setHighVoltage(DEFAULT_HIGH_VOLTAGE);
//Initialization of acquistion parameters
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
@ -286,6 +295,24 @@ int64_t getTimeLeft(enum timerIndex ind){
}
int setHighVoltage(int val){
#ifdef VIRTUAL
if (val >= 0)
highvoltage = val;
return highvoltage;
#endif
// setting hv
if (val >= 0) {
FILE_LOG(logINFO, ("Setting High voltage: %d V", val));
DAC6571_Set(val);
highvoltage = val;
}
return highvoltage;
}
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport) {
#ifdef VIRTUAL
char cDestIp[MAX_STR_LENGTH];

View File

@ -5,14 +5,22 @@
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
/* Enums */
enum DACINDEX {DAC0};
/* Hardware Definitions */
#define NCHAN (128)
#define NCHIP (10)
#define NDAC (16)
#define TEMP_CLK (20) /* MHz */
#define HV_SOFT_MAX_VOLTAGE (200)
#define HV_HARD_MAX_VOLTAGE (530)
#define HV_DRIVER_FILE_NAME ("/root/devlinks/hvdac")
/** Default Parameters */
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (1 * 1000 * 1000) // 1 ms
#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s
#define DEFAULT_PERIOD (1 * 1000 * 1000 * 1000) // 1 s
#define DEFAULT_HIGH_VOLTAGE (0)

View File

@ -215,7 +215,7 @@ void powerOff();
int getADC(enum ADCINDEX ind);
#endif
#endif
#if !defined(MYTHEN3D) && !defined(GOTTHARD2D)
#if !defined(MYTHEN3D)
int setHighVoltage(int val);
#endif

View File

@ -3,6 +3,8 @@
#include "common.h"
#include "sls_detector_defs.h"
#include "string.h"
/* DAC6571 HV DEFINES */
#define DAC6571_MIN_DAC_VAL (0x0)
#define DAC6571_MAX_DAC_VAL (0x3FF)
@ -42,7 +44,7 @@ int DAC6571_Set (int val) {
//open file
FILE* fd=fopen(DAC6571_DriverFileName,"w");
if (fd==NULL) {
FILE_LOG(logERROR, ("Could not open file for writing to set high voltage\n"));
FILE_LOG(logERROR, ("Could not open file %s for writing to set high voltage\n", DAC6571_DriverFileName));
return FAIL;
}
//convert to string, add 0 and write to file

View File

@ -654,7 +654,7 @@ int set_dac(int file_des) {
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
return printSocketReadError();
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
#if defined(MYTHEN3D)
functionNotImplemented();
#else
@ -779,6 +779,9 @@ int set_dac(int file_des) {
case HIGH_VOLTAGE:
case V_LIMIT:
break;
#elif GOTTHARD2D
case HIGH_VOLTAGE:
break;
#endif
default:
#ifdef JUNGFRAUD
@ -841,7 +844,7 @@ int set_dac(int file_des) {
case HIGH_VOLTAGE:
retval = setHighVoltage(val);
FILE_LOG(logDEBUG1, ("High Voltage: %d\n", retval));
#if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD)
#if defined(JUNGFRAUD) || defined (CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARD2D)
validate(val, retval, "set high voltage", DEC);
#endif
#ifdef GOTTHARDD
@ -945,7 +948,10 @@ int set_dac(int file_des) {
validate(val, retval, "set vlimit", DEC);
break;
#endif
#ifdef GOTTHARD2D
default:
break;
#elif
// dacs
default:
if (mV && val > DAC_MAX_MV) {
@ -1001,6 +1007,7 @@ 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

@ -9,4 +9,4 @@
#define APIJUNGFRAU 0x190830
#define APIMYTHEN3 0x190830
#define APIEIGER 0x190830
#define APIGOTTHARD2 0x190830
#define APIGOTTHARD2 0x190902