lucabaldini / xpedaq

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

trigger mask not updated if trgmask.cfg is empty #152

Closed csgro closed 7 years ago

csgro commented 7 years ago

I had the impression today that if trgmask.cfg is empty, xped daq does not force all pixels to be enabled, but just does nothing. If in a previous run some pixels where masked, they remain so. But all in the log file indicates that no pixels are masked. Need to make sure that in this case we force an enable-all instruction.

lucabaldini commented 7 years ago

Can you look at a log file and see if "Enabling all pixels to trigger... " is there? If that is the case, then we need Massimo to debug the funciton.

/* Enable all the pixels to trigger.
 */
void pXpolFpga::enableAllPixels()
{
  *xpollog::kInfo << "Enabling all pixels to trigger... ";
  setupToDisablePixels();
  serialWrite(XPOL_SIGNAL_REG, 0x4);
  serialWrite(XPOL_SIGNAL_REG, 0x0);
  *xpollog::kInfo << "Done." << endline;
}

/* Mask a single pixel.
 */
void pXpolFpga::maskPixel(unsigned short x, unsigned short y)
{
  setupToDisablePixels();
  writeAddress(x, y);
  serialWrite(XPOL_DISPIX_REG, 0x1); //disable pixel
  serialWrite(XPOL_DISPIX_REG, 0x0);
}

/* Apply a trigger mask.
 */
void pXpolFpga::applyTriggerMask(pTriggerMask *trgMask)
{
  if (trgMask->size()) {
    enableAllPixels();
    //setupToDisablePixels();
    for (const auto &chan : *(trgMask->mask())) {
      *xpollog::kInfo << "Masking pixel <" << chan.first << ", " 
              << chan.second << ">... " << endline;
      writeAddress(chan.first, chan.second);
      serialWrite(XPOL_DISPIX_REG, 0x1); //disable pixel
      serialWrite(XPOL_DISPIX_REG, 0x0);
    }
  }
}

/* In order to mask a pixel to the trigger XPOL must be configured in 
   READMODE 0 and WRITEMODE 0.
 */
void pXpolFpga::setupToDisablePixels()
{
  serialWrite(15, 0x0); // To send configuration to XPOL SIMODE must be 0.
  serialWrite(TOXPOL_MSB_REG,((0x0&0x3f)>>4)&0x03);
  serialWrite(TOXPOL_MID_REG,((0x0&0x3f)<<4)&0xf0);
  serialWrite(XPOL_SI_CNT_REG,reset_XPOLSI);
  serialWrite(XPOL_SI_CNT_REG,0);
  serialWrite(XPOL_SI_CNT_REG,WSEL);//WSEL=1 CONFIGURATION mode
  serialWrite(XPOL_SI_CNT_REG,SEND|WSEL);//WSEL=1 CONFIGURATION mode
  serialWrite(XPOL_SI_CNT_REG,0);
}
lucabaldini commented 7 years ago

No, it is not! if the list of noisy pixels is empty the ASIC keeps the previous setting.

run 001_0000718, 31 pixels masked, rate ~ 2Hz and "Enabling all pixels to trigger... " than masking in log file - OK run 001_0000719, no pixels masked (removed all pixels in trgmask.cfg), rate ~2 Hz (expected 200 Hz!) and NOT "Enabling all pixels to trigger... " in log file

Here the guilty code: if (trgMask->size()) { enableAllPixels();

lucabaldini commented 7 years ago

enableAllPixels() moved before the if (trgMask->size()) condition in pXpolFpga.cpp Commit 49c3836