Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 207 → Rev 265

/cvi/instr/DRS/drsread.cpp
109,12 → 109,78
 
static DRS *drs=NULL;
 
 
DLLEXPORT int DRSCalibrateTiming( )
{
DRSBoard *b;
if (drs == NULL) drs = new DRS();
if (!drs) return -1;
DRSParameters = drssettings::instance();
//fCalMode = 2;
if (drs->GetNumberOfBoards() ) {
/* continue working with first board only */
b = drs->GetBoard(0);
if (b->GetFirmwareVersion() < 13279)
printf("Firmware revision 13279 or later\nrequired for timing calibration\n");
else if (b->GetInputRange() != 0)
printf("Timing calibration can only be done\nat the -0.5V to +0.5V input range\n");
 
else {
 
 
/* remember current settings */
double acalVolt = b->GetAcalVolt();
int acalMode = b->GetAcalMode();
int tcalFreq = b->GetTcalFreq();
int tcalLevel = b->GetTcalLevel();
int tcalSource = b->GetTcalSource();
int flag1 = b->GetTriggerEnable(0);
int flag2 = b->GetTriggerEnable(1);
int trgSource = b->GetTriggerSource();
int trgDelay = b->GetTriggerDelay();
double range = b->GetInputRange();
int config = b->GetReadoutChannelConfig();
 
int status = b->CalibrateTiming(NULL);
 
if (!status)
printf("Error performing timing calibration, please check waveforms and redo voltage calibration.\n");
else
printf("Timing calibration successfully finished.\n");
 
/* restore old values */
b->EnableAcal(acalMode, acalVolt);
b->EnableTcal(tcalFreq, tcalLevel);
b->SelectClockSource(tcalSource);
b->EnableTrigger(flag1, flag2);
b->SetTriggerSource(trgSource);
b->SetTriggerDelayPercent(trgDelay);
b->SetInputRange(range);
b->SetChannelConfig(config, 8, 8);
 
if (b->GetBoardType() == 5)
b->SetTranspMode(1); // Evaluation board with build-in trigger
else
b->SetTranspMode(1); // VPC Mezzanine board
 
return status;
}
}
return -1;
}
 
 
DLLEXPORT int DRSInit()
{
 
DRSBoard *b;
/* do drsinitial scan */
drs = new DRS();
if (drs == NULL) drs = new DRS();
if (!drs) return -1;
DRSParameters = drssettings::instance();