mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
ctb bug fix: slow adcs incorrect mv read out, needed clk down and usleep before reading
This commit is contained in:
Binary file not shown.
@ -126,7 +126,6 @@ int AD7689_GetTemperature() {
|
|||||||
// overwrite configuration
|
// overwrite configuration
|
||||||
AD7689_CFG_CFG_OVRWRTE_VAL);
|
AD7689_CFG_CFG_OVRWRTE_VAL);
|
||||||
|
|
||||||
// FIXME: do we have to read it 8 times?? (sequencer is disabled anyway) or are we sequencing, then we read only last channel
|
|
||||||
int regval = AD7689_Get();
|
int regval = AD7689_Get();
|
||||||
|
|
||||||
// value in mV FIXME: page 17? reference voltage temperature coefficient or t do with -40 to 85 °C
|
// value in mV FIXME: page 17? reference voltage temperature coefficient or t do with -40 to 85 °C
|
||||||
@ -138,8 +137,7 @@ int AD7689_GetTemperature() {
|
|||||||
|
|
||||||
// value in °C
|
// value in °C
|
||||||
double tempValue = AD7689_TMP_C_FOR_1_MV * (double)retval;
|
double tempValue = AD7689_TMP_C_FOR_1_MV * (double)retval;
|
||||||
|
FILE_LOG(logINFO, ("\ttemp read : %f °C (%d unit)\n", tempValue, regval));
|
||||||
FILE_LOG(logINFO, ("\ttemp read : %f °C\n", tempValue));
|
|
||||||
|
|
||||||
return tempValue;
|
return tempValue;
|
||||||
|
|
||||||
@ -169,7 +167,6 @@ int AD7689_GetChannel(int ichan) {
|
|||||||
// overwrite configuration
|
// overwrite configuration
|
||||||
AD7689_CFG_CFG_OVRWRTE_VAL);
|
AD7689_CFG_CFG_OVRWRTE_VAL);
|
||||||
|
|
||||||
// FIXME: do we have to read it 8 times?? (sequencer is disabled anyway) or are we sequencing, then we read only last channel
|
|
||||||
int regval = AD7689_Get();
|
int regval = AD7689_Get();
|
||||||
|
|
||||||
// value in mV
|
// value in mV
|
||||||
|
@ -8,12 +8,15 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
|
|||||||
FILE_LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
FILE_LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||||
*valw, addr, csmask, clkmask, digoutmask, convBit));
|
*valw, addr, csmask, clkmask, digoutmask, convBit));
|
||||||
|
|
||||||
// needed for the slow adcs for apprx 20 ns before and after rising of convbit (usleep val is vague assumption)
|
|
||||||
if (convBit)
|
|
||||||
usleep(20);
|
|
||||||
|
|
||||||
// start point
|
// start point
|
||||||
(*valw) = ((bus_r(addr) | csmask | clkmask) &(~digoutmask));
|
if (convBit) {
|
||||||
|
// needed for the slow adcs for apprx 20 ns before and after rising of convbit (usleep val is vague assumption)
|
||||||
|
usleep(20);
|
||||||
|
// clkmask has to be down for conversion to have correct value (for conv bit = 1)
|
||||||
|
(*valw) = (((bus_r(addr) | csmask) &(~clkmask)) &(~digoutmask));
|
||||||
|
} else {
|
||||||
|
(*valw) = ((bus_r(addr) | csmask | clkmask) &(~digoutmask));
|
||||||
|
}
|
||||||
bus_w (addr, (*valw));
|
bus_w (addr, (*valw));
|
||||||
FILE_LOG(logDEBUG2, ("startpoint. valw:0x%08x\n", *valw));
|
FILE_LOG(logDEBUG2, ("startpoint. valw:0x%08x\n", *valw));
|
||||||
|
|
||||||
@ -93,6 +96,7 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
|
|||||||
|
|
||||||
uint32_t retval = 0;
|
uint32_t retval = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < numbitstoreceive; ++i) {
|
for (i = 0; i < numbitstoreceive; ++i) {
|
||||||
|
|
||||||
// clk down
|
// clk down
|
||||||
@ -104,11 +108,16 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
|
|||||||
retval |= ((bus_r(readaddr) & 0x1) << (numbitstoreceive - 1 - i));
|
retval |= ((bus_r(readaddr) & 0x1) << (numbitstoreceive - 1 - i));
|
||||||
FILE_LOG(logDEBUG2, ("read data %d. retval:0x%08x\n", i, retval));
|
FILE_LOG(logDEBUG2, ("read data %d. retval:0x%08x\n", i, retval));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
// clk up
|
// clk up
|
||||||
(*valw) |= clkmask ;
|
(*valw) |= clkmask ;
|
||||||
bus_w (addr, (*valw));
|
bus_w (addr, (*valw));
|
||||||
FILE_LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
FILE_LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +144,8 @@ uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive,
|
|||||||
|
|
||||||
uint32_t retval = receiveDataFromSPI(&valw, addr, numbitstoreceive, clkmask, readaddr);
|
uint32_t retval = receiveDataFromSPI(&valw, addr, numbitstoreceive, clkmask, readaddr);
|
||||||
|
|
||||||
SPIChipDeselect(&valw, addr, csmask, clkmask, digoutmask, convBit); // moving this before bringin up earlier changes temp of slow adc
|
// not needed for conv bit (not a chip select)
|
||||||
|
//SPIChipDeselect(&valw, addr, csmask, clkmask, digoutmask, convBit); // moving this before bringin up earlier changes temp of slow adc
|
||||||
|
|
||||||
if (numbitstoreceive == 16) {
|
if (numbitstoreceive == 16) {
|
||||||
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
|
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
|
||||||
|
@ -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 */
|
/** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 in mV */
|
||||||
Result<int> getSlowADC(defs::dacIndex index, Positions pos = {}) const;
|
Result<int> getSlowADC(defs::dacIndex index, Positions pos = {}) const;
|
||||||
|
|
||||||
/** [CTB]*/
|
/** [CTB]*/
|
||||||
|
@ -1400,7 +1400,7 @@ std::string CmdProxy::SlowAdc(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[n_channel (0-7 for channel|8 for temperature)]\n\t[Ctb] Slow "
|
os << "[n_channel (0-7 for channel|8 for temperature)]\n\t[Ctb] Slow "
|
||||||
"ADC channel."
|
"ADC channel in mV or °C."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
@ -1416,7 +1416,7 @@ 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) << '\n';
|
os << OutString(t) << " mV\n";
|
||||||
}
|
}
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
throw sls::RuntimeError("cannot put");
|
throw sls::RuntimeError("cannot put");
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define APIMOENCH 0x200131
|
#define APIMOENCH 0x200131
|
||||||
#define APIGOTTHARD2 0x200226
|
#define APIGOTTHARD2 0x200226
|
||||||
#define APIMYTHEN3 0x200226
|
#define APIMYTHEN3 0x200226
|
||||||
#define APICTB 0x200226
|
|
||||||
#define APIJUNGFRAU 0x200226
|
#define APIJUNGFRAU 0x200226
|
||||||
#define APIEIGER 0x200226
|
#define APIEIGER 0x200226
|
||||||
#define APIGOTTHARD 0x200226
|
#define APIGOTTHARD 0x200226
|
||||||
|
#define APICTB 0x200227
|
||||||
|
Reference in New Issue
Block a user