mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-07 13:20:02 +02:00
hv should work now
This commit is contained in:
parent
0fdbac981e
commit
111856ed7b
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#define PORTNAME "/dev/ttyBF1"
|
#define PORTNAME "/dev/ttyBF1"
|
||||||
#define GOODBYE 200
|
#define GOODBYE 200
|
||||||
#define BUFFERSIZE 255
|
#define BUFFERSIZE 16
|
||||||
#define I2C_DEVICE_FILE "/dev/i2c-0"
|
#define I2C_DEVICE_FILE "/dev/i2c-0"
|
||||||
#define I2C_DEVICE_ADDRESS 0x4C
|
#define I2C_DEVICE_ADDRESS 0x4C
|
||||||
//#define I2C_DEVICE_ADDRESS 0x48
|
//#define I2C_DEVICE_ADDRESS 0x48
|
||||||
@ -119,13 +119,12 @@ int main(int argc, char* argv[]) {
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int ival= 0;
|
int ival= 0;
|
||||||
char buffer[BUFFERSIZE]="";
|
char buffer[BUFFERSIZE];
|
||||||
|
buffer[BUFFERSIZE-2] = '\0';
|
||||||
|
buffer[BUFFERSIZE-1] = '\n';
|
||||||
cprintf(GREEN,"Ready...\n");
|
cprintf(GREEN,"Ready...\n");
|
||||||
|
|
||||||
while(ret != GOODBYE){
|
while(ret != GOODBYE){
|
||||||
memset(buffer, 0, BUFFERSIZE);
|
|
||||||
buffer[BUFFERSIZE-1]='\n';
|
|
||||||
|
|
||||||
n = read(fd,buffer,BUFFERSIZE);
|
n = read(fd,buffer,BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||||
@ -140,9 +139,9 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(i2c_write(ival)<0)
|
if(i2c_write(ival)<0)
|
||||||
strcpy(buffer,"failed");
|
strcpy(buffer,"fail ");
|
||||||
else
|
else
|
||||||
strcpy(buffer,"successful");
|
strcpy(buffer,"success ");
|
||||||
cprintf(GREEN,"%s\n",buffer);
|
cprintf(GREEN,"%s\n",buffer);
|
||||||
n = write(fd, buffer, BUFFERSIZE);
|
n = write(fd, buffer, BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -154,9 +153,9 @@ int main(int argc, char* argv[]) {
|
|||||||
ival = i2c_read();
|
ival = i2c_read();
|
||||||
//ok/ fail
|
//ok/ fail
|
||||||
if(ival < 0)
|
if(ival < 0)
|
||||||
strcpy(buffer,"failed");
|
strcpy(buffer,"fail ");
|
||||||
else
|
else
|
||||||
strcpy(buffer,"successful");
|
strcpy(buffer,"success ");
|
||||||
n = write(fd, buffer, BUFFERSIZE);
|
n = write(fd, buffer, BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||||
@ -164,7 +163,7 @@ int main(int argc, char* argv[]) {
|
|||||||
//value
|
//value
|
||||||
if(ival >= 0){
|
if(ival >= 0){
|
||||||
cprintf(GREEN,"%d\n",ival);
|
cprintf(GREEN,"%d\n",ival);
|
||||||
sprintf(buffer,"%d\n",ival);
|
sprintf(buffer,"%d ",ival);
|
||||||
n = write(fd, buffer, BUFFERSIZE);
|
n = write(fd, buffer, BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||||
@ -177,7 +176,7 @@ int main(int argc, char* argv[]) {
|
|||||||
ret = GOODBYE;
|
ret = GOODBYE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown Command\n");
|
printf("Unknown Command. buffer:%s\n",buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,18 +219,14 @@ int Feb_Control_Init(int master, int top, int normal, int module_num){
|
|||||||
if(Feb_Control_activated)
|
if(Feb_Control_activated)
|
||||||
Feb_Interface_SetByteOrder();
|
Feb_Interface_SetByteOrder();
|
||||||
|
|
||||||
//master of 9M, set up high voltage serial communication to blackfin
|
|
||||||
if(Feb_control_master && !Feb_control_normal){
|
|
||||||
if(!Feb_Control_SetupSerialCommunication())
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Feb_Control_SetupSerialCommunication(){
|
int Feb_Control_OpenSerialCommunication(){
|
||||||
|
cprintf(BG_BLUE,"opening serial communication of hv\n");
|
||||||
|
if(Feb_Control_hv_fd != -1)
|
||||||
|
close(Feb_Control_hv_fd);
|
||||||
Feb_Control_hv_fd = open(SPECIAL9M_HIGHVOLTAGE_PORT, O_RDWR | O_NOCTTY);
|
Feb_Control_hv_fd = open(SPECIAL9M_HIGHVOLTAGE_PORT, O_RDWR | O_NOCTTY);
|
||||||
if(Feb_Control_hv_fd < 0){
|
if(Feb_Control_hv_fd < 0){
|
||||||
cprintf(RED,"Warning: Unable to open port %s to set up high voltage serial communciation to the blackfin\n", SPECIAL9M_HIGHVOLTAGE_PORT);
|
cprintf(RED,"Warning: Unable to open port %s to set up high voltage serial communciation to the blackfin\n", SPECIAL9M_HIGHVOLTAGE_PORT);
|
||||||
@ -258,6 +254,11 @@ int Feb_Control_SetupSerialCommunication(){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Feb_Control_CloseSerialCommunication(){
|
||||||
|
if(Feb_Control_hv_fd != -1)
|
||||||
|
close(Feb_Control_hv_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Feb_Control_PrintModuleList(){
|
void Feb_Control_PrintModuleList(){
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -376,7 +377,8 @@ int Feb_Control_CheckSetup(int master){
|
|||||||
ok=0;
|
ok=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((Feb_control_master) &&(Module_GetHighVoltage(&modules[i])<0)){
|
int value = 0;
|
||||||
|
if((Feb_control_master) && (!Feb_Control_GetHighVoltage(&value))){
|
||||||
cprintf(RED,"Warning: module %d's high voltage not set.\n",Module_GetModuleNumber(&modules[i]));
|
cprintf(RED,"Warning: module %d's high voltage not set.\n",Module_GetModuleNumber(&modules[i]));
|
||||||
ok=0;
|
ok=0;
|
||||||
}
|
}
|
||||||
@ -525,7 +527,7 @@ float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vm
|
|||||||
|
|
||||||
//only master gets to call this function
|
//only master gets to call this function
|
||||||
int Feb_Control_SetHighVoltage(int value){
|
int Feb_Control_SetHighVoltage(int value){
|
||||||
printf(" Setting High Voltage: %dV\t",value);
|
printf(" Setting High Voltage:\t");
|
||||||
/*
|
/*
|
||||||
* maximum voltage of the hv dc/dc converter:
|
* maximum voltage of the hv dc/dc converter:
|
||||||
* 300 for single module power distribution board
|
* 300 for single module power distribution board
|
||||||
@ -544,9 +546,9 @@ int Feb_Control_SetHighVoltage(int value){
|
|||||||
//calculate dac value
|
//calculate dac value
|
||||||
if(!Feb_Control_VoltageToDAC(value,&dacval,nsteps,vmin,vlimit)){
|
if(!Feb_Control_VoltageToDAC(value,&dacval,nsteps,vmin,vlimit)){
|
||||||
cprintf(RED,"\nWarning: SetHighVoltage bad value, %d. The range is 0 to %d V.\n",value, (int)vlimit);
|
cprintf(RED,"\nWarning: SetHighVoltage bad value, %d. The range is 0 to %d V.\n",value, (int)vlimit);
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
printf("(%d dac): ",dacval);
|
printf("(%d dac):\t%dV\n", dacval, value);
|
||||||
|
|
||||||
return Feb_Control_SendHighVoltage(dacval);
|
return Feb_Control_SendHighVoltage(dacval);
|
||||||
}
|
}
|
||||||
@ -596,30 +598,34 @@ int Feb_Control_SendHighVoltage(int dacvalue){
|
|||||||
|
|
||||||
//9m
|
//9m
|
||||||
else{
|
else{
|
||||||
|
/*Feb_Control_OpenSerialCommunication();*/
|
||||||
if (Feb_Control_hv_fd == -1){
|
if (Feb_Control_hv_fd == -1){
|
||||||
cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n");
|
cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE]="";
|
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||||
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
|
||||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
||||||
int n = 0;
|
int n = 0;
|
||||||
sprintf(buffer,"p%d",dacvalue);
|
sprintf(buffer,"p%d ",dacvalue);
|
||||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSEI
|
||||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//ok/fail
|
//ok/fail
|
||||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSEI
|
||||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
if(buffer[0] == 'f'){
|
fflush(stdout);
|
||||||
|
/*Feb_Control_CloseSerialCommunication();*/
|
||||||
|
if(buffer[0] != 's'){
|
||||||
cprintf(RED,"\nError: Failed to set high voltage\n");
|
cprintf(RED,"\nError: Failed to set high voltage\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
cprintf(GREEN,"%s\n",buffer);
|
cprintf(GREEN,"%s\n",buffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -667,34 +673,38 @@ int Feb_Control_ReceiveHighVoltage(unsigned int* value){
|
|||||||
|
|
||||||
//9m
|
//9m
|
||||||
else{
|
else{
|
||||||
|
/*Feb_Control_OpenSerialCommunication();*/
|
||||||
|
|
||||||
if (Feb_Control_hv_fd == -1){
|
if (Feb_Control_hv_fd == -1){
|
||||||
cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n");
|
cprintf(RED,"\nWarning: High voltage serial communication not set up for 9m\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE]="";
|
char buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE];
|
||||||
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-2]='\0';
|
||||||
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
buffer[SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE-1]='\n';
|
||||||
int n = 0;
|
int n = 0;
|
||||||
//request
|
//request
|
||||||
strcpy(buffer,"g");
|
strcpy(buffer,"g ");
|
||||||
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = write(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSEI
|
||||||
cprintf(BLUE,"Sent %d Bytes\n", n);
|
cprintf(BLUE,"Sent %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//ok/fail
|
//ok/fail
|
||||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSEI
|
||||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
if(buffer[0] == 'f'){
|
if(buffer[0] != 's'){
|
||||||
cprintf(RED,"\nWarning: failed to read high voltage\n");
|
cprintf(RED,"\nWarning: failed to read high voltage\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
n = read(Feb_Control_hv_fd, buffer, SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSEI
|
||||||
cprintf(BLUE,"Received %d Bytes\n", n);
|
cprintf(BLUE,"Received %d Bytes\n", n);
|
||||||
#endif
|
#endif
|
||||||
|
/*Feb_Control_OpenSerialCommunication();*/
|
||||||
if (!sscanf(buffer,"%d",value)){
|
if (!sscanf(buffer,"%d",value)){
|
||||||
cprintf(RED,"\nWarning: failed to scan high voltage read\n");
|
cprintf(RED,"\nWarning: failed to scan high voltage read\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -112,7 +112,8 @@ int Feb_Control_GetModuleNumber();
|
|||||||
|
|
||||||
void Feb_Control_FebControl();
|
void Feb_Control_FebControl();
|
||||||
int Feb_Control_Init(int master, int top, int normal, int module_num);
|
int Feb_Control_Init(int master, int top, int normal, int module_num);
|
||||||
int Feb_Control_SetupSerialCommunication();
|
int Feb_Control_OpenSerialCommunication();
|
||||||
|
void Feb_Control_CloseSerialCommunication();
|
||||||
int Feb_Control_CheckSetup();
|
int Feb_Control_CheckSetup();
|
||||||
|
|
||||||
unsigned int Feb_Control_GetNModules();
|
unsigned int Feb_Control_GetNModules();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
CC = powerpc-4xx-softfloat-gcc
|
CC = powerpc-4xx-softfloat-gcc
|
||||||
CCX = powerpc-4xx-softfloat-g++
|
CCX = powerpc-4xx-softfloat-g++
|
||||||
BLACKFIN_CC = bfin-uclinux-gcc
|
BLACKFIN_CC = bfin-uclinux-gcc
|
||||||
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
|
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
|
||||||
LDLIBS += -lm -lstdc++
|
LDLIBS += -lm -lstdc++
|
||||||
|
|
||||||
PROGS = eigerDetectorServer
|
PROGS = eigerDetectorServer
|
||||||
@ -36,7 +36,7 @@ beb_debug:$(SRC_CLNT3)
|
|||||||
mv beb_debug $(DESTDIR)
|
mv beb_debug $(DESTDIR)
|
||||||
|
|
||||||
hv9m_blackfin_server:9mhvserial_bf.c
|
hv9m_blackfin_server:9mhvserial_bf.c
|
||||||
$(BLACKFIN_CC) -o hv9m_blackfin_server 9mhvserial_bf.c -Wall
|
$(BLACKFIN_CC) -o hv9m_blackfin_server 9mhvserial_bf.c -Wall #-DVERBOSE
|
||||||
mv hv9m_blackfin_server $(DESTDIR)
|
mv hv9m_blackfin_server $(DESTDIR)
|
||||||
rm hv9m_blackfin_server.gdb
|
rm hv9m_blackfin_server.gdb
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -144,6 +144,11 @@ int initDetector(){
|
|||||||
Feb_Interface_FebInterface();
|
Feb_Interface_FebInterface();
|
||||||
Feb_Control_FebControl();
|
Feb_Control_FebControl();
|
||||||
Feb_Control_Init(master,top,normal, getDetectorNumber());
|
Feb_Control_Init(master,top,normal, getDetectorNumber());
|
||||||
|
//master of 9M, check high voltage serial communication to blackfin
|
||||||
|
if(master && !normal){
|
||||||
|
if(Feb_Control_OpenSerialCommunication())
|
||||||
|
;// Feb_Control_CloseSerialCommunication();
|
||||||
|
}
|
||||||
printf("FEB Initialization done\n");
|
printf("FEB Initialization done\n");
|
||||||
Beb_Beb();
|
Beb_Beb();
|
||||||
printf("BEB Initialization done\n");
|
printf("BEB Initialization done\n");
|
||||||
@ -162,7 +167,6 @@ int initDetector(){
|
|||||||
eiger_photonenergy = -1;
|
eiger_photonenergy = -1;
|
||||||
setReadOutFlags(NONPARALLEL);
|
setReadOutFlags(NONPARALLEL);
|
||||||
setSpeed(0,1);//clk_devider,half speed
|
setSpeed(0,1);//clk_devider,half speed
|
||||||
setHighVoltage(0,0);
|
|
||||||
setIODelay(650,0);
|
setIODelay(650,0);
|
||||||
setTiming(AUTO_TIMING);
|
setTiming(AUTO_TIMING);
|
||||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||||
@ -170,6 +174,7 @@ int initDetector(){
|
|||||||
int enable[2] = {0,1};
|
int enable[2] = {0,1};
|
||||||
setExternalGating(enable);//disable external gating
|
setExternalGating(enable);//disable external gating
|
||||||
Feb_Control_SetInTestModeVariable(0);
|
Feb_Control_SetInTestModeVariable(0);
|
||||||
|
setHighVoltage(0,0);
|
||||||
Feb_Control_CheckSetup();
|
Feb_Control_CheckSetup();
|
||||||
|
|
||||||
//print detector mac and ip
|
//print detector mac and ip
|
||||||
@ -436,13 +441,18 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
|
|||||||
int setHighVoltage(int val, int imod){
|
int setHighVoltage(int val, int imod){
|
||||||
if(val!=-1){
|
if(val!=-1){
|
||||||
eiger_highvoltage = val;
|
eiger_highvoltage = val;
|
||||||
if(master)
|
if(master){
|
||||||
Feb_Control_SetHighVoltage(val);
|
int ret = Feb_Control_SetHighVoltage(val);
|
||||||
|
if(!ret) //could not set
|
||||||
|
return -2;
|
||||||
|
else if (ret == -1) //outside range
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(master && !Feb_Control_GetHighVoltage(&eiger_highvoltage)){
|
if(master && !Feb_Control_GetHighVoltage(&eiger_highvoltage)){
|
||||||
cprintf(RED,"Warning: Could not read high voltage\n");
|
cprintf(RED,"Warning: Could not read high voltage\n");
|
||||||
return 0;
|
return -3;
|
||||||
}
|
}
|
||||||
return eiger_highvoltage;
|
return eiger_highvoltage;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ enum detNetworkParameter{TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
|
|||||||
#define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input"
|
#define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input"
|
||||||
#define NORMAL_HIGHVOLTAGE_OUTPUTPORT "/sys/class/hwmon/hwmon5/device/out0_output"
|
#define NORMAL_HIGHVOLTAGE_OUTPUTPORT "/sys/class/hwmon/hwmon5/device/out0_output"
|
||||||
#define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1"
|
#define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1"
|
||||||
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE 8
|
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE 16
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1259,16 +1259,30 @@ int set_dac(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//takes time to set high voltage, so no check for it
|
//takes time to set high voltage, so no check for it
|
||||||
if(ret == OK && ind != HV_POT && ind != HV_NEW){
|
if(ret == OK){
|
||||||
if(mV)
|
if(ind != HV_POT && ind != HV_NEW){
|
||||||
temp = retval[1];
|
|
||||||
else
|
if(mV)
|
||||||
temp = retval[0];
|
temp = retval[1];
|
||||||
if ((abs(temp-val)<=5) || val==-1) {
|
else
|
||||||
ret=OK;
|
temp = retval[0];
|
||||||
} else {
|
if ((abs(temp-val)<=5) || val==-1) {
|
||||||
ret=FAIL;
|
ret=OK;
|
||||||
printf("Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
|
} else {
|
||||||
|
ret=FAIL;
|
||||||
|
printf("Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if(retval[0] < 0){
|
||||||
|
if(retval[0] == -1)
|
||||||
|
sprintf(mess, "Setting high voltage failed.Bad value %d. The range is from 0 to 200 V.\n",val);
|
||||||
|
else if(retval[0] == -2)
|
||||||
|
strcpy(mess, "Setting high voltage failed. Serial/i2c communication failed.\n");
|
||||||
|
else if(retval[0] == -3)
|
||||||
|
strcpy(mess, "Getting high voltage failed. Serial/i2c communication failed.\n");
|
||||||
|
ret = FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user