lucabaldini / xpedaq

Data acquisition software for the X-ray polarimetry explorers
GNU General Public License v2.0
0 stars 0 forks source link

Keep track and correct for the vref drift #137

Open lucabaldini opened 7 years ago

lucabaldini commented 7 years ago

A few notes from a discussion with Ronaldo.

We observed the vref drifting with time and, since the trigger threshold is referred to vref, if we do not compensate for it, we might have a change with time of the trigger efficiency and/or the window size and the pulse height.

We want to:

  1. keep track of the vref on a buffer-by-buffer basis (this will likely require a change in the data format.)
  2. correct the trigger threshold at runtime on a buffer-by-buffer basis, so that the effective trigger threshold does not change with time.
lucabaldini commented 7 years ago

It seems like most of the relevant code is in

pXpolFpga::setDacThreshold(pDetectorConfiguration *configuration)

and if I parse the code correctly, here we're setting the threshold DAC for the 16 buffers and the calibration DAC at the same time. The threshold DAC is referred to vref in the function

// Reads the reference voltage in DAC and sum it to the thresholds - To Be Fixed later
unsigned short vref_dac = readVrefDac();
for(int i=0;i<15;i++)
  copythreshold[i] = trh_buffer[i]+ (unsigned short)(vref_dac*AD2_LSB/DAC_LSB);

so all we need is a function call every time a buffer is read out.

lucabaldini commented 7 years ago

And, on a related note, we might consider splitting the functions setting the threshold DAC and the calibration DAC, so that we're not forced to set both of them all the time.

lucabaldini commented 7 years ago

We do have a first hack in place. One thing to notice is that it only makes sense to do this in windowed mode (and as a matter of fact if we call the setDacThreshold() method while running in full frame the system just hangs after the first buffer). The code reads

  if (!m_fullFrame) {
pXpolFpga xpol(m_usbController);
xpol.setDacThreshold(m_detectorConfiguration);
  }
lucabaldini commented 7 years ago

Ok, there's a first implementation correcting for the vref every 10 seconds---hard-coded in pDataCollector.

In the future we might want to write the value of the vref along with the buffer in the output binary file, but this requires a change in the data format, so it needs planning.