ctb adc: get in uV and print in client in mV to get decimals

This commit is contained in:
maliakal_d 2020-02-27 15:43:42 +01:00
parent 10ba16a9dc
commit 2e2e91b219
5 changed files with 21 additions and 13 deletions

View File

@ -68,6 +68,8 @@
#define AD7689_INT_REF_MAX_MV (2500) // chosen using reference buffer selection in config reg #define AD7689_INT_REF_MAX_MV (2500) // chosen using reference buffer selection in config reg
#define AD7689_INT_REF_MIN_MV (0) #define AD7689_INT_REF_MIN_MV (0)
#define AD7689_INT_REF_MAX_UV (2500 * 1000)
#define AD7689_INT_REF_MIN_UV (0)
#define AD7689_INT_MAX_STEPS (0xFFFF + 1) #define AD7689_INT_MAX_STEPS (0xFFFF + 1)
#define AD7689_TMP_C_FOR_1_MV (25.00 / 283.00) #define AD7689_TMP_C_FOR_1_MV (25.00 / 283.00)
@ -169,13 +171,15 @@ int AD7689_GetChannel(int ichan) {
int regval = AD7689_Get(); int regval = AD7689_Get();
// value in mV // value in uV
int retval = 0; int retval = ((double)(regval - 0) * (double)(AD7689_INT_REF_MAX_UV - AD7689_INT_REF_MIN_UV))
ConvertToDifferentRange(0, AD7689_INT_MAX_STEPS, / (double)(AD7689_INT_MAX_STEPS - 0) + AD7689_INT_REF_MIN_UV;
AD7689_INT_REF_MIN_MV, AD7689_INT_REF_MAX_MV,
regval, &retval);
FILE_LOG(logINFO, ("\tvoltage read for chan %d: %d mV\n", ichan, retval));
/*ConvertToDifferentRange(0, AD7689_INT_MAX_STEPS,
AD7689_INT_REF_MIN_MV, AD7689_INT_REF_MAX_MV,
regval, &retval);*/
FILE_LOG(logINFO, ("\tvoltage read for chan %d: %d uV (regVal: %d)\n", ichan, retval, regval));
return retval; return retval;
} }

View File

@ -1036,7 +1036,7 @@ class Detector {
Result<int> getMeasuredCurrent(defs::dacIndex index, Result<int> getMeasuredCurrent(defs::dacIndex index,
Positions pos = {}) const; Positions pos = {}) const;
/** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 in mV */ /** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 in uV */
Result<int> getSlowADC(defs::dacIndex index, Positions pos = {}) const; Result<int> getSlowADC(defs::dacIndex index, Positions pos = {}) const;
/** [CTB]*/ /** [CTB]*/

View File

@ -1416,7 +1416,11 @@ std::string CmdProxy::SlowAdc(int action) {
} else { } else {
auto t = det->getSlowADC( auto t = det->getSlowADC(
static_cast<defs::dacIndex>(nchan + defs::SLOW_ADC0), {det_id}); static_cast<defs::dacIndex>(nchan + defs::SLOW_ADC0), {det_id});
os << OutString(t) << " mV\n"; Result<double> result(t.size());
for (unsigned int i = 0; i < t.size(); ++i) {
result[i] = t[i] / 1000.00;
}
os << OutString(result) << " mV\n";
} }
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
throw sls::RuntimeError("cannot put"); throw sls::RuntimeError("cannot put");

View File

@ -6,7 +6,7 @@
#define APIJUNGFRAU 0x200226 #define APIJUNGFRAU 0x200226
#define APIEIGER 0x200226 #define APIEIGER 0x200226
#define APIGOTTHARD 0x200226 #define APIGOTTHARD 0x200226
#define APICTB 0x200227
#define APILIB 0x200227 #define APILIB 0x200227
#define APIRECEIVER 0x200227 #define APIRECEIVER 0x200227
#define APIGUI 0x200227 #define APIGUI 0x200227
#define APICTB 0x200227