diff --git a/slsDetectorServers/slsDetectorServer/AD7689.h b/slsDetectorServers/slsDetectorServer/AD7689.h
index 0adfbf46b..d06dcfb52 100755
--- a/slsDetectorServers/slsDetectorServer/AD7689.h
+++ b/slsDetectorServers/slsDetectorServer/AD7689.h
@@ -61,13 +61,13 @@
#define AD7689_ADC_CFG_NUMBITS (14)
#define AD7689_ADC_DATA_NUMBITS (16)
-#define AD7689_NUM_CHANNELS (7)
+#define AD7689_NUM_CHANNELS (8)
#define AD7689_NUM_INVALID_CONVERSIONS (3)
#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_MAX_STEPS (0xFFFF + 1)
-#define AD7689_TMP_C_FOR_1_MV (25.00 / 283)
+#define AD7689_TMP_C_FOR_1_MV (25.00 / 283.00)
uint32_t AD7689_Reg = 0x0;
@@ -87,6 +87,8 @@ int AD7689_DigOffset = 0x0;
* @param dofst digital output offset
*/
void AD7689_SetDefines(uint32_t reg, uint32_t roreg, uint32_t cmsk, uint32_t clkmsk, uint32_t dmsk, int dofst) {
+ FILE_LOG(logDEBUG, ("AD7689: reg:0x%x roreg:0x%x cmsk:0x%x clkmsk:0x%x dmsk:0x%x dofst:%d\n",
+ reg, roreg, cmsk, clkmsk, dmsk, dofst));
AD7689_Reg = reg;
AD7689_ROReg = roreg;
AD7689_CnvMask = cmsk;
@@ -100,9 +102,9 @@ void AD7689_SetDefines(uint32_t reg, uint32_t roreg, uint32_t cmsk, uint32_t clk
*/
void AD7689_Disable() {
bus_w(AD7689_Reg, (bus_r(AD7689_Reg)
- | AD7689_CnvMask
- | AD7689_ClkMask)
- &~(AD7689_DigMask));
+ &~(AD7689_CnvMask)
+ | AD7689_ClkMask
+ &~(AD7689_DigMask)));
}
/**
@@ -112,7 +114,7 @@ void AD7689_Disable() {
void AD7689_Set(u_int32_t codata) {
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Writing 0x%08x to Config Reg\n", codata));
serializeToSPI(AD7689_Reg, codata, AD7689_CnvMask, AD7689_ADC_CFG_NUMBITS,
- AD7689_ClkMask, AD7689_DigMask, AD7689_DigOffset);
+ AD7689_ClkMask, AD7689_DigMask, AD7689_DigOffset, 1);
}
/**
@@ -121,8 +123,8 @@ void AD7689_Set(u_int32_t codata) {
*/
uint16_t AD7689_Get() {
FILE_LOG(logINFO, ("\tGetting ADC SPI Register.\n"));
- return (uint16_t)serializeFromSPI(AD7689_ROReg, AD7689_Reg, AD7689_CnvMask, AD7689_ADC_DATA_NUMBITS,
- AD7689_ClkMask, AD7689_DigMask);
+ return (uint16_t)serializeFromSPI(AD7689_Reg, AD7689_CnvMask, AD7689_ADC_DATA_NUMBITS,
+ AD7689_ClkMask, AD7689_DigMask, AD7689_ROReg, 1);
}
/**
@@ -154,13 +156,14 @@ int AD7689_GetTemperature() {
ConvertToDifferentRange(0, AD7689_INT_MAX_STEPS,
AD7689_INT_REF_MIN_MV, AD7689_INT_REF_MAX_MV,
regval, &retval);
- FILE_LOG(logDEBUG1, ("\tvoltage read for temp: 0x%d mV\n", retval));
+ FILE_LOG(logDEBUG1, ("voltage read for temp: %d mV\n", retval));
// value in °C
- int temp = AD7689_TMP_C_FOR_1_MV * retval;
- FILE_LOG(logDEBUG1, ("\ttemp read: 0x%d °C\n", temp));
+ double tempValue = AD7689_TMP_C_FOR_1_MV * (double)retval;
- return temp;
+ FILE_LOG(logINFO, ("\ttemp read : %f °C\n", tempValue));
+
+ return tempValue;
}
@@ -201,7 +204,7 @@ int AD7689_GetChannel(int ichan) {
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: 0x%d mV\n", retval));
+ FILE_LOG(logINFO, ("\tvoltage read for chan %d: %d mV\n", ichan, retval));
return retval;
}
diff --git a/slsDetectorServers/slsDetectorServer/AD9257.h b/slsDetectorServers/slsDetectorServer/AD9257.h
index 52e363f5e..5568a1082 100755
--- a/slsDetectorServers/slsDetectorServer/AD9257.h
+++ b/slsDetectorServers/slsDetectorServer/AD9257.h
@@ -183,7 +183,7 @@ void AD9257_Set(int addr, int val) {
codata = val + (addr << 8);
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
serializeToSPI(AD9257_Reg, codata, AD9257_CsMask, AD9257_ADC_NUMBITS,
- AD9257_ClkMask, AD9257_DigMask, AD9257_DigOffset);
+ AD9257_ClkMask, AD9257_DigMask, AD9257_DigOffset, 0);
}
/**
diff --git a/slsDetectorServers/slsDetectorServer/LTC2620.h b/slsDetectorServers/slsDetectorServer/LTC2620.h
index 77cd63346..538ceedd3 100755
--- a/slsDetectorServers/slsDetectorServer/LTC2620.h
+++ b/slsDetectorServers/slsDetectorServer/LTC2620.h
@@ -106,15 +106,15 @@ int LTC2620_DacToVoltage(int dacval, int* voltage) {
* @param dacaddr dac channel number in chip
*/
void LTC2620_SetSingle(int cmd, int data, int dacaddr) {
- FILE_LOG(logDEBUG1, ("(Single) dac addr:%d, dac value:%d, cmd:%d\n", dacaddr, data, cmd));
+ FILE_LOG(logDEBUG2, ("(Single) dac addr:%d, dac value:%d, cmd:%d\n", dacaddr, data, cmd));
uint32_t codata = (((data << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK) |
((dacaddr << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) |
cmd);
- FILE_LOG(logDEBUG1, ("codata: 0x%x\n", codata));
+ FILE_LOG(logDEBUG2, ("codata: 0x%x\n", codata));
serializeToSPI (LTC2620_Reg, codata, LTC2620_CsMask, LTC2620_NUMBITS,
- LTC2620_ClkMask, LTC2620_DigMask, LTC2620_DigOffset);
+ LTC2620_ClkMask, LTC2620_DigMask, LTC2620_DigOffset, 0);
}
@@ -143,24 +143,24 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
uint32_t valw = 0;
int ichip = 0;
- FILE_LOG(logDEBUG1, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, val:%d, cmd:0x%x \n",
+ FILE_LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, val:%d, cmd:0x%x \n",
chipIndex, nchip, dacaddr, data, cmd));
// data to be bit banged
uint32_t codata = (((data << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK) |
((dacaddr << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) |
cmd);
- FILE_LOG(logDEBUG1, ("codata: 0x%x\n", codata));
+ FILE_LOG(logDEBUG2, ("codata: 0x%x\n", codata));
// select all chips (ctb daisy chain; others 1 chip)
- FILE_LOG(logDEBUG1, ("Selecting LTC2620\n"));
+ FILE_LOG(logDEBUG2, ("Selecting LTC2620\n"));
SPIChipSelect (&valw, LTC2620_Reg, LTC2620_CsMask, LTC2620_ClkMask, LTC2620_DigMask);
// send same data to all
if (chipIndex < 0) {
- FILE_LOG(logDEBUG1, ("Send same data to all\n"));
+ FILE_LOG(logDEBUG2, ("Send same data to all\n"));
for (ichip = 0; ichip < nchip; ++ichip) {
- FILE_LOG(logDEBUG1, ("Send data (0x%x) to ichip %d\n", codata, ichip));
+ FILE_LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, ichip));
LTC2620_SendDaisyData(&valw, codata);
}
}
@@ -169,24 +169,24 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
else {
// send nothing to subsequent ichips (daisy chain) (if any chips after desired chip)
for (ichip = chipIndex + 1; ichip < nchip; ++ichip) {
- FILE_LOG(logDEBUG1, ("Send nothing to ichip %d\n", ichip));
+ FILE_LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
}
// send data to desired chip
- FILE_LOG(logDEBUG1, ("Send data (0x%x) to ichip %d\n", codata, chipIndex));
+ FILE_LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, chipIndex));
LTC2620_SendDaisyData(&valw, codata);
// send nothing to preceding ichips (daisy chain) (if any chips in front of desired chip)
for (ichip = 0; ichip < chipIndex; ++ichip) {
- FILE_LOG(logDEBUG1, ("Send nothing to ichip %d\n", ichip));
+ FILE_LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
}
}
// deselect all chips (ctb daisy chain; others 1 chip)
- FILE_LOG(logDEBUG1, ("Deselecting LTC2620\n"));
- SPIChipDeselect(&valw, LTC2620_Reg, LTC2620_CsMask, LTC2620_ClkMask);
+ FILE_LOG(logDEBUG2, ("Deselecting LTC2620\n"));
+ SPIChipDeselect(&valw, LTC2620_Reg, LTC2620_CsMask, LTC2620_ClkMask, LTC2620_DigMask, 0);
}
@@ -200,14 +200,14 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
*/
void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) {
FILE_LOG(logDEBUG1, ("cmd:0x%x, data:%d, dacaddr:%d, chipIndex:%d\n", cmd, data, dacaddr, chipIndex));
- FILE_LOG(logDEBUG1, (" ================================================\n"));
+ FILE_LOG(logDEBUG2, (" ================================================\n"));
// ctb
if (LTC2620_Ndac > LTC2620_NUMCHANNELS)
LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex);
// others
else
LTC2620_SetSingle(cmd, data, dacaddr);
- FILE_LOG(logDEBUG1, (" ================================================\n"));
+ FILE_LOG(logDEBUG2, (" ================================================\n"));
}
diff --git a/slsDetectorServers/slsDetectorServer/MAX1932.h b/slsDetectorServers/slsDetectorServer/MAX1932.h
index 662f90117..99aabed01 100755
--- a/slsDetectorServers/slsDetectorServer/MAX1932.h
+++ b/slsDetectorServers/slsDetectorServer/MAX1932.h
@@ -88,7 +88,7 @@ int MAX1932_Set (int val) {
FILE_LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
serializeToSPI(MAX1932_Reg, dacvalue, MAX1932_CsMask, MAX1932_HV_NUMBITS,
- MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset);
+ MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0);
return OK;
}
diff --git a/slsDetectorServers/slsDetectorServer/commonServerFunctions.h b/slsDetectorServers/slsDetectorServer/commonServerFunctions.h
index a69aad8a7..644dc6cce 100755
--- a/slsDetectorServers/slsDetectorServer/commonServerFunctions.h
+++ b/slsDetectorServers/slsDetectorServer/commonServerFunctions.h
@@ -18,8 +18,8 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
}
-void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask) {
- FILE_LOG(logDEBUG2, ("SPI chip deselect. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x\n",
+void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask, int convBit) {
+ FILE_LOG(logDEBUG2, ("SPI chip deselect. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x\n",
*valw, addr, csmask, clkmask));
// chip sel bar up
@@ -33,7 +33,12 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
// stop point = start point of course
- (*valw) |= csmask;
+ (*valw) &= ~digoutmask;
+ if (convBit) {
+ (*valw) &= ~csmask;
+ } else {
+ (*valw) |= csmask;
+ }
bus_w (addr, (*valw)); //FIXME: for ctb slow adcs, might need to set it to low again
FILE_LOG(logDEBUG2, ("stop point. valw:0x%08x\n", *valw));
}
@@ -88,7 +93,7 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
return retval;
}
-void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstosend, uint32_t clkmask, uint32_t digoutmask, int digofset) {
+void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstosend, uint32_t clkmask, uint32_t digoutmask, int digofset, int convBit) {
if (numbitstosend == 16) {
FILE_LOG(logDEBUG2, ("Writing to SPI Register: 0x%04x\n", val));
} else {
@@ -100,10 +105,10 @@ void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstos
sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
- SPIChipDeselect(&valw, addr, csmask, clkmask);
+ SPIChipDeselect(&valw, addr, csmask, clkmask, digoutmask, convBit);
}
-uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive, uint32_t clkmask, uint32_t digoutmask, uint32_t readaddr) {
+uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive, uint32_t clkmask, uint32_t digoutmask, uint32_t readaddr, int convBit) {
uint32_t valw;
@@ -111,7 +116,7 @@ uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive,
uint32_t retval = receiveDataFromSPI(&valw, addr, numbitstoreceive, clkmask, readaddr);
- SPIChipDeselect(&valw, addr, csmask, clkmask);
+ SPIChipDeselect(&valw, addr, csmask, clkmask, digoutmask, convBit); // moving this before bringin up earlier changes temp of slow adc
if (numbitstoreceive == 16) {
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
index bb13a3609..b3dcd43cb 100644
--- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
+++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
@@ -1203,7 +1203,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page settings
- - v_chip [i] mv Sets/gets value for Vchip on the new chiptest board. Must be in mV. \c Returns \c (int ["mV"]). Normally don't use it!
+ - v_chip [i] mv Sets/gets value for Vchip on the new chiptest board. Must be in mV. \c Returns \c (int ["mV"]). Do NOT use it, unless you are completely sure you won't fry the board!
*/
descrToFuncMap[i].m_pFuncName = "v_chip"; //
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDAC;