eiger blocking trigger WIP, new fw, 3 bits: 1 for exp, 1 for falling exp toggle, 1 for rising exp toggle

This commit is contained in:
maliakal_d 2021-06-07 15:00:06 +02:00
parent 238b6e8753
commit 48cef99e62
3 changed files with 39 additions and 21 deletions

View File

@ -998,15 +998,17 @@ int Feb_Control_StartAcquisition() {
int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); } int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); }
int Feb_Control_GetExposureStatus(int *toggle, int *exposure) { int Feb_Control_GetExposureStatus(int *rising, int *falling, int *exposure) {
unsigned int value = 0; unsigned int value = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(), FEB_REG_STATUS, if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(), FEB_REG_STATUS,
&value)) { &value)) {
LOG(logERROR, ("Could not read FEB_REG_STATUS reg\n")); LOG(logERROR, ("Could not read FEB_REG_STATUS reg\n"));
return 0; return 0;
} }
*toggle = *rising = ((value & FEB_REG_STATUS_EXP_TGL_RISING_MSK) >>
((value & FEB_REG_STATUS_EXP_TGL_MSK) >> FEB_REG_STATUS_EXP_TGL_OFST); FEB_REG_STATUS_EXP_TGL_RISING_OFST);
*falling = ((value & FEB_REG_STATUS_EXP_TGL_FALLING_MSK) >>
FEB_REG_STATUS_EXP_TGL_FALLING_OFST);
*exposure = ((value & FEB_REG_STATUS_EXP_MSK) >> FEB_REG_STATUS_EXP_OFST); *exposure = ((value & FEB_REG_STATUS_EXP_MSK) >> FEB_REG_STATUS_EXP_OFST);
return 1; return 1;
} }
@ -1037,30 +1039,37 @@ int Feb_Control_SendSoftwareTrigger() {
return 0; return 0;
} }
LOG(logINFO, ("Software Internal Trigger Sent!\n")); LOG(logINFO, ("Software Internal Trigger Sent!\n"));
return 1;
} }
int Feb_Control_SoftwareTrigger(int block) { int Feb_Control_SoftwareTrigger(int block) {
if (Feb_Control_activated) { if (Feb_Control_activated) {
int prev_toggle = 0, toggle = 0, prev_exposure = 0, exposure = 0; int rising = 0, falling = 0, exposure = 0;
if (!Feb_Control_GetExposureStatus(&rising, &falling, &exposure)) {
// remember previous toggle
if (!Feb_Control_GetExposureStatus(&prev_toggle, &exposure)) {
return 0; return 0;
} }
if (exposure) {
LOG(logERROR, ("Software trigger failed. Still exposing.\n"));
return 0;
}
// remember previous rising toggle
int prev_toggle = rising;
Feb_Control_SendSoftwareTrigger(); Feb_Control_SendSoftwareTrigger();
// wait for trigger for 20ms // will need to wait if delay after trigger introduced
usleep(0); // usleep(0);
// get current toggle value // get current toggle value
if (!Feb_Control_GetExposureStatus(&toggle, &exposure)) { if (!Feb_Control_GetExposureStatus(&rising, &falling, &exposure)) {
return 0; return 0;
} }
// no toggle error // no toggle error
if (toggle == prev_toggle) { if (rising == prev_toggle) {
LOG(logERROR, ("Software trigger failed. No exposure toggle " LOG(logERROR, ("Software trigger failed. No exposure toggle "
"detected.\n")); "detected.\n"));
return 0; return 0;
@ -1071,16 +1080,23 @@ int Feb_Control_SoftwareTrigger(int block) {
LOG(logERROR, ("Software trigger failed. No exposure detected.\n")); LOG(logERROR, ("Software trigger failed. No exposure detected.\n"));
return 0; return 0;
} }
prev_exposure = exposure;
// wait for exposure to be done // wait for exposure to be done
if (block) { if (block) {
while (prev_exposure == exposure) { prev_toggle = falling;
while (prev_toggle == falling) {
usleep(5000); usleep(5000);
if (!Feb_Control_GetExposureStatus(&prev_toggle, &exposure)) { if (!Feb_Control_GetExposureStatus(&rising, &falling,
&exposure)) {
return 0; return 0;
} }
} }
// exposure low
if (exposure) {
LOG(logERROR, ("Software trigger failed. Still exposing after "
"exposure finished toggled.\n"));
return 0;
}
} }
} }
return 1; return 1;

View File

@ -55,7 +55,7 @@ int Feb_Control_PrepareForAcquisition();
void Feb_Control_PrintAcquisitionSetup(); void Feb_Control_PrintAcquisitionSetup();
int Feb_Control_StartAcquisition(); int Feb_Control_StartAcquisition();
int Feb_Control_StopAcquisition(); int Feb_Control_StopAcquisition();
int Feb_Control_GetExposureStatus(int *toggle, int *exposure); int Feb_Control_GetExposureStatus(int *rising, int *falling, int *exposure);
int Feb_Control_SendSoftwareTrigger(); int Feb_Control_SendSoftwareTrigger();
int Feb_Control_SoftwareTrigger(int block); int Feb_Control_SoftwareTrigger(int block);

View File

@ -32,12 +32,14 @@
#define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register #define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register
#define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3) #define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3)
#define FEB_REG_STATUS_EXP_OFST (5) #define FEB_REG_STATUS_EXP_OFST (5)
#define FEB_REG_STATUS_EXP_MSK (0x00000001 << FEB_REG_STATUS_EXP_OFST) #define FEB_REG_STATUS_EXP_MSK (0x00000001 << FEB_REG_STATUS_EXP_OFST)
#define FEB_REG_STATUS_EXP_TGL_OFST (6) #define FEB_REG_STATUS_EXP_TGL_FALLING_OFST (6)
#define FEB_REG_STATUS_EXP_TGL_MSK (0x00000001 << FEB_REG_STATUS_EXP_TGL_OFST) #define FEB_REG_STATUS_EXP_TGL_FALLING_MSK (0x00000001 << FEB_REG_STATUS_EXP_TGL_FALLING_OFST)
#define FEB_REG_STATUS_TEMP_OFST (16) #define FEB_REG_STATUS_EXP_TGL_RISING_OFST (7)
#define FEB_REG_STATUS_TEMP_MSK (0x0000FFFF << FEB_REG_STATUS_TEMP_OFST) #define FEB_REG_STATUS_EXP_TGL_RISING_MSK (0x00000001 << FEB_REG_STATUS_EXP_TGL_RISING_OFST)
#define FEB_REG_STATUS_TEMP_OFST (16)
#define FEB_REG_STATUS_TEMP_MSK (0x0000FFFF << FEB_REG_STATUS_TEMP_OFST)
#define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4) #define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4)
#define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5) #define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5)