diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index f748834a3..d175a5cca 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -2034,10 +2034,10 @@ class Detector(CppDetectorApi): ----- [Jungfrau][Moench] FULL_SPEED, HALF_SPEED (Default), QUARTER_SPEED [Eiger] FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED + [Moench] FULL_SPEED (Default), HALF_SPEED, QUARTER_SPEED [Gottthard2] G2_108MHZ (Default), G2_144MHZ [Jungfrau] FULL_SPEED option only available from v2.0 boards and is recommended to set number of interfaces to 2. \n Also overwrites adcphase to recommended default. - [Moench] FULL_SPEED (Default) """ return element_if_equal(self.getReadoutSpeed()) diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index 6f1903513..d7335950b 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -43,6 +43,7 @@ void qTabDataOutput::SetupWidgetWindow() { case slsDetectorDefs::MYTHEN3: chkParallel->setEnabled(true); break; + case slsDetectorDefs::MOENCH: case slsDetectorDefs::JUNGFRAU: lblClkDivider->setEnabled(true); comboClkDivider->setEnabled(true); diff --git a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h index c6a01515e..65a9590ab 100644 --- a/slsDetectorServers/moenchDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/moenchDetectorServer/RegisterDefs.h @@ -167,6 +167,11 @@ #define CONFIG_OPRTN_MDE_2_X_10GbE_MSK (0x00000001 << CONFIG_OPRTN_MDE_2_X_10GbE_OFST) #define CONFIG_INNR_PRIMRY_INTRFCE_OFST (17) #define CONFIG_INNR_PRIMRY_INTRFCE_MSK (0x00000001 << CONFIG_INNR_PRIMRY_INTRFCE_OFST) +#define CONFIG_READOUT_SPEED_OFST (20) +#define CONFIG_READOUT_SPEED_MSK (0x00000003 << CONFIG_READOUT_SPEED_OFST) +#define CONFIG_QUARTER_SPEED_10MHZ_VAL ((0x0 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK) +#define CONFIG_HALF_SPEED_20MHZ_VAL ((0x1 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK) +#define CONFIG_FULL_SPEED_40MHZ_VAL ((0x2 << CONFIG_READOUT_SPEED_OFST) & CONFIG_READOUT_SPEED_MSK) #define CONFIG_TDMA_ENABLE_OFST (24) #define CONFIG_TDMA_ENABLE_MSK (0x00000001 << CONFIG_TDMA_ENABLE_OFST) #define CONFIG_TDMA_TIMESLOT_OFST (25) // 1ms diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 8b3b64fee..7ab321225 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index e2e716447..6708a264e 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1411,23 +1411,37 @@ int setReadoutSpeed(int val) { // stop state machine if running if (runBusy()) { stopStateMachine(); + return FAIL; + } + if (isHardwareVersion_1_0()) { + LOG(logERROR, ("Cannot set full speed. Not implemented for this pcb version (1.0)\n")); + return FAIL; } - uint32_t adcOfst = 0; - uint32_t sampleAdcSpeed = 0; - uint32_t adcPhase = 0; + uint32_t config = 0; + uint32_t sampleAdcDecimationFactor = 0; switch (val) { case FULL_SPEED: - if (isHardwareVersion_1_0()) { - LOG(logERROR, ("Cannot set full speed. Should not be here\n")); - return FAIL; - } LOG(logINFO, ("Setting Full Speed (40 MHz):\n")); - sampleAdcSpeed = SAMPLE_ADC_FULL_SPEED; - adcPhase = ADC_PHASE_DEG_FULL_SPEED; - adcOfst = ADC_OFST_FULL_SPEED_VAL; + config = CONFIG_FULL_SPEED_40MHZ_VAL; + sampleAdcDecimationFactor = ADC_DECMT_FULL_SPEED + << SAMPLE_ADC_DECMT_FACTOR_OFST; + break; + + case HALF_SPEED: + LOG(logINFO, ("Setting Speed Speed (20 MHz):\n")); + config = CONFIG_HALF_SPEED_20MHZ_VAL; + sampleAdcDecimationFactor = ADC_DECMT_HALF_SPEED + << SAMPLE_ADC_DECMT_FACTOR_OFST; + break; + + case QUARTER_SPEED: + LOG(logINFO, ("Setting Quarter Speed (10 MHz):\n")); + config = CONFIG_QUARTER_SPEED_10MHZ_VAL; + sampleAdcDecimationFactor = ADC_DECMT_QUARTER_SPEED + << SAMPLE_ADC_DECMT_FACTOR_OFST; break; default: @@ -1435,23 +1449,35 @@ int setReadoutSpeed(int val) { return FAIL; } - bus_w(ADC_OFST_REG, (bus_r(ADC_OFST_REG) & ~ADC_OFFSET_MSK)); - bus_w(ADC_OFST_REG, (bus_r(ADC_OFST_REG) | - ((adcOfst << ADC_OFFSET_OFST) & ADC_OFFSET_MSK))); - LOG(logINFO, ("\tSet ADC Ofst Reg to 0x%x\n", - ((bus_r(ADC_OFST_REG) & ADC_OFFSET_MSK) >> ADC_OFFSET_OFST))); + bus_w(CONFIG_REG, bus_r(CONFIG_REG) & ~CONFIG_READOUT_SPEED_MSK); + bus_w(CONFIG_REG, bus_r(CONFIG_REG) | config); + LOG(logINFO, ("\tSet Config Reg to 0x%x\n", bus_r(CONFIG_REG))); - bus_w(SAMPLE_REG, sampleAdcSpeed); + bus_w(SAMPLE_REG, bus_r(SAMPLE_REG) & ~SAMPLE_ADC_DECMT_FACTOR_MSK); + bus_w(SAMPLE_REG, bus_r(SAMPLE_REG) | sampleAdcDecimationFactor); LOG(logINFO, ("\tSet Sample Reg to 0x%x\n", bus_r(SAMPLE_REG))); - setPhase(ADC_CLK, adcPhase, 1); - LOG(logINFO, ("\tSet ADC Phase Reg to %d deg\n", adcPhase)); - + // TODO: adcofst, adcphase? return OK; } int getReadoutSpeed(int *retval) { - *retval = FULL_SPEED; + u_int32_t speed = bus_r(CONFIG_REG) & CONFIG_READOUT_SPEED_MSK; + switch (speed) { + case CONFIG_FULL_SPEED_40MHZ_VAL: + *retval = FULL_SPEED; + break; + case CONFIG_HALF_SPEED_20MHZ_VAL: + *retval = HALF_SPEED; + break; + case CONFIG_QUARTER_SPEED_10MHZ_VAL: + *retval = QUARTER_SPEED; + break; + default: + LOG(logERROR, ("Unknown speed val: %d\n", speed)); + *retval = -1; + return FAIL; + } return OK; } diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h index faf74ac67..0bdb3b962 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h @@ -65,6 +65,10 @@ #define MAX_PHASE_SHIFTS (240) #define BIT16_MASK (0xFFFF) +#define ADC_DECMT_QUARTER_SPEED (0x3) +#define ADC_DECMT_HALF_SPEED (0x1) +#define ADC_DECMT_FULL_SPEED (0x0) + // pipeline #define ADC_PORT_INVERT_VAL (0x55555555) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 1d991713e..ba4f65034 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -9438,10 +9438,8 @@ int set_readout_speed(int file_des) { switch (arg) { #if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD) case FULL_SPEED: -#ifndef MOENCHD case HALF_SPEED: case QUARTER_SPEED: -#endif #elif GOTTHARD2D case G2_108MHZ: case G2_144MHZ: diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index ee972f903..adb5ba447 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -708,8 +708,7 @@ std::string CmdProxy::ReadoutSpeed(int action) { "full_speed option only available from v2.0 boards and is " "recommended to set number of interfaces to 2. Also overwrites " "adcphase to recommended default.\n\t [144|108]\n\t\t[Gotthard2] " - "Readout speed of chip in MHz. Default is 108.\n\t\t[Moench] " - "Only Full speed is implemented." + "Readout speed of chip in MHz. Default is 108." << '\n'; } else { defs::detectorType type = det->getDetectorType().squash(); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index dc43cb396..b9a3f3967 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -506,10 +506,9 @@ std::vector Detector::getReadoutSpeedList() const { switch (getDetectorType().squash()) { case defs::EIGER: case defs::JUNGFRAU: + case defs::MOENCH: return std::vector{defs::FULL_SPEED, defs::HALF_SPEED, defs::QUARTER_SPEED}; - case defs::MOENCH: - return std::vector{defs::FULL_SPEED}; case defs::GOTTHARD2: return std::vector{defs::G2_108MHZ, defs::G2_144MHZ}; default: diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index b4ec67abf..96f8d864e 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1050,9 +1050,9 @@ TEST_CASE("readoutspeed", "[.cmd]") { // full speed for jungfrau/moench only works for new boards (chipv1.1 is // with new board [hw1.0 and chipv1.0 not tested here]) - if (((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) && + if (((det_type == defs::JUNGFRAU) && det.getChipVersion().squash() * 10 == 11) || - (det_type == defs::EIGER)) { + (det_type == defs::EIGER) || (det_type == defs::MOENCH)) { std::ostringstream oss1, oss2, oss3, oss4; proxy.Call("readoutspeed", {"0"}, -1, PUT, oss1); REQUIRE(oss1.str() == "readoutspeed full_speed\n"); diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index d4eb71e9a..901bce1d5 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -8,6 +8,6 @@ #define APIGOTTHARD "developer 0x230615" #define APIGOTTHARD2 "developer 0x230615" #define APIJUNGFRAU "developer 0x230615" -#define APIMOENCH "developer 0x230615" #define APICTB "developer 0x230621" #define APIMYTHEN3 "developer 0x230621" +#define APIMOENCH "developer 0x230707"