hv should work now

This commit is contained in:
Dhanya Maliakal
2017-01-06 15:16:05 +01:00
parent 0fdbac981e
commit 111856ed7b
9 changed files with 88 additions and 54 deletions

View File

@ -1259,16 +1259,30 @@ int set_dac(int file_des) {
#endif
//takes time to set high voltage, so no check for it
if(ret == OK && ind != HV_POT && ind != HV_NEW){
if(mV)
temp = retval[1];
else
temp = retval[0];
if ((abs(temp-val)<=5) || val==-1) {
ret=OK;
} else {
ret=FAIL;
printf("Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
if(ret == OK){
if(ind != HV_POT && ind != HV_NEW){
if(mV)
temp = retval[1];
else
temp = retval[0];
if ((abs(temp-val)<=5) || val==-1) {
ret=OK;
} 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;
}
}
}