also save TRG-OUT setting, change PHA default channel setting
This commit is contained in:
parent
972c249076
commit
0a6f866f7a
|
@ -234,6 +234,7 @@ void Digitizer::ErrorMsg(string header){
|
||||||
|
|
||||||
int Digitizer::ProgramBoard(){
|
int Digitizer::ProgramBoard(){
|
||||||
|
|
||||||
|
printf("----- program Board\n");
|
||||||
ret = CAEN_DGTZ_Reset(handle);
|
ret = CAEN_DGTZ_Reset(handle);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("ERROR: can't reset the digitizer.\n");
|
printf("ERROR: can't reset the digitizer.\n");
|
||||||
|
@ -291,7 +292,7 @@ void Digitizer::StartACQ(){
|
||||||
ErrorMsg("Start ACQ");
|
ErrorMsg("Start ACQ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Acquisition Started for Board %d\n", boardID);
|
printf("\e[1m\e[33m======= Acquisition Started for Board %d\e[0m\n", boardID);
|
||||||
AcqRun = true;
|
AcqRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,11 +340,18 @@ void Digitizer::ReadData(){
|
||||||
printf(" extracted %d events in ch-%02d\n", NumEvents[i], i);
|
printf(" extracted %d events in ch-%02d\n", NumEvents[i], i);
|
||||||
}
|
}
|
||||||
ErrorMsg("GetDPPEvents");
|
ErrorMsg("GetDPPEvents");
|
||||||
|
|
||||||
|
FILE * haha = fopen("output.bin", "w+");
|
||||||
|
|
||||||
|
fwrite(buffer, BufferSize, 1, haha);
|
||||||
|
fclose(haha);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================
|
//===========================================================
|
||||||
void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
|
void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
|
||||||
/// only for channel setting.
|
if( address < 0x8000){
|
||||||
|
///printf("0x%x, 0x%x=%u, ch:%d\n", address, value, value, ch);
|
||||||
if( ch < 0 ) {
|
if( ch < 0 ) {
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, address + 0x7000, value);
|
ret = CAEN_DGTZ_WriteRegister(handle, address + 0x7000, value);
|
||||||
for( int i = 0; i < NChannel; i++) EditByte(value, address + (i << 8));
|
for( int i = 0; i < NChannel; i++) EditByte(value, address + (i << 8));
|
||||||
|
@ -351,6 +359,9 @@ void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, address + (ch<<8), value);
|
ret = CAEN_DGTZ_WriteRegister(handle, address + (ch<<8), value);
|
||||||
EditByte( value, address + (ch<<8) );
|
EditByte( value, address + (ch<<8) );
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
ret = CAEN_DGTZ_WriteRegister(handle, address, value);
|
||||||
|
}
|
||||||
ErrorMsg("WriteRegister");
|
ErrorMsg("WriteRegister");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,16 +389,14 @@ void Digitizer::SetChannelMask(uint32_t mask){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SetRecordLength(unsigned int ns, int ch){
|
void Digitizer::SetRecordLength(unsigned int ns, int ch){
|
||||||
int ch_coupled = ch + int(pow(-1, ch));
|
|
||||||
WriteRegister( Register::DPP::RecordLength_G, ns / ch2ns / 8 , ch);
|
WriteRegister( Register::DPP::RecordLength_G, ns / ch2ns / 8 , ch);
|
||||||
WriteRegister( Register::DPP::RecordLength_G, ns / ch2ns / 8 , ch_coupled);
|
if( ch >= 0 ) WriteRegister( Register::DPP::RecordLength_G, ns / ch2ns / 8 , ch + int(pow(-1, ch)));
|
||||||
ErrorMsg("SetRecordLength");
|
ErrorMsg("SetRecordLength");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){
|
void Digitizer::SetEventAggregation(unsigned int numEvent, int ch){
|
||||||
int ch_coupled = ch + int(pow(-1, ch));
|
|
||||||
WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch);
|
WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch);
|
||||||
WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch_coupled);
|
if( ch >= 0 ) WriteRegister( Register::DPP::NumberEventsPerAggregate_G,numEvent, ch + int(pow(-1, ch)));
|
||||||
ErrorMsg("SetEventAggregation");
|
ErrorMsg("SetEventAggregation");
|
||||||
}
|
}
|
||||||
void Digitizer::SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch){ WriteRegister( Register::DPP::InputDynamicRange, TwoVol_0_or_halfVol_1, ch); ErrorMsg("SetInputDynamicRange");}
|
void Digitizer::SetInputDynamicRange(unsigned int TwoVol_0_or_halfVol_1, int ch){ WriteRegister( Register::DPP::InputDynamicRange, TwoVol_0_or_halfVol_1, ch); ErrorMsg("SetInputDynamicRange");}
|
||||||
|
@ -454,11 +463,15 @@ void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
|
void Digitizer::SetBits(uint32_t address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
|
||||||
|
///printf("address : 0x%x, value : 0x%x, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
|
||||||
uint32_t bit ;
|
uint32_t bit ;
|
||||||
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
|
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
|
||||||
if (ch < 0 ) ch = 0; /// take ch-0
|
int tempCh = ch;
|
||||||
bit = ReadRegister(address, ch);
|
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
|
||||||
|
bit = ReadRegister(address, tempCh);
|
||||||
|
///printf("bit : 0x%x, bitmask : 0x%x \n", bit, bitmask);
|
||||||
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
|
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
|
||||||
|
///printf("bit : 0x%x, ch : %d \n", bit, ch);
|
||||||
WriteRegister(address, bit, ch);
|
WriteRegister(address, bit, ch);
|
||||||
if( ret != 0 ) ErrorMsg("SetBits");
|
if( ret != 0 ) ErrorMsg("SetBits");
|
||||||
}
|
}
|
||||||
|
@ -584,17 +597,21 @@ void Digitizer::CreateAndSaveSettingBinary(string fileName){
|
||||||
settingFileExist = true;
|
settingFileExist = true;
|
||||||
|
|
||||||
///Save board setting
|
///Save board setting
|
||||||
EditByteByRegister(Register::DPP::BoardConfiguration);
|
EditByteByRegister(Register::DPP::BoardConfiguration); /// 0x8000
|
||||||
EditByteByRegister(Register::DPP::GlobalTriggerMask);
|
EditByteByRegister(Register::DPP::GlobalTriggerMask); /// 0x810C
|
||||||
EditByteByRegister(Register::DPP::ChannelEnableMask);
|
EditByteByRegister(Register::DPP::ChannelEnableMask); /// 0x8120
|
||||||
EditByteByRegister(Register::DPP::ROM_BoardVersion);
|
EditByteByRegister(Register::DPP::FrontPanelTRGOUTEnableMask); /// 0x8110
|
||||||
EditByteByRegister(Register::DPP::ROM_BoardFromFactor);
|
EditByteByRegister(Register::DPP::FrontPanelIOControl); /// 0x811C
|
||||||
EditByteByRegister(Register::DPP::ROM_BoardIDByte1);
|
EditByteByRegister(Register::DPP::DisableExternalTrigger); /// 0x817C
|
||||||
EditByteByRegister(Register::DPP::ROM_BoardIDByte0);
|
EditByteByRegister(Register::DPP::TriggerValidationMask); /// 0x8180
|
||||||
EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte1);
|
EditByteByRegister(Register::DPP::ROM_BoardVersion); /// 0xF030
|
||||||
EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte0);
|
EditByteByRegister(Register::DPP::ROM_BoardFromFactor); /// 0xF034
|
||||||
EditByteByRegister(Register::DPP::ROCFPGAFirmwareRevision);
|
EditByteByRegister(Register::DPP::ROM_BoardIDByte1); /// 0xF038
|
||||||
EditByteByRegister(Register::DPP::BoardInfo);
|
EditByteByRegister(Register::DPP::ROM_BoardIDByte0); /// 0xF03C
|
||||||
|
EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte1); /// 0xF080
|
||||||
|
EditByteByRegister(Register::DPP::ROM_BoardSerialNumByte0); /// 0xF084
|
||||||
|
EditByteByRegister(Register::DPP::ROCFPGAFirmwareRevision); /// 0x8124
|
||||||
|
EditByteByRegister(Register::DPP::BoardInfo); /// 0x8140
|
||||||
|
|
||||||
///================ channel settings
|
///================ channel settings
|
||||||
for( int ch = 0; ch < NChannel ; ch++){
|
for( int ch = 0; ch < NChannel ; ch++){
|
||||||
|
|
|
@ -13,8 +13,8 @@ DigitizerPHA::~DigitizerPHA(){
|
||||||
}
|
}
|
||||||
|
|
||||||
int DigitizerPHA::ProgramBoard(){
|
int DigitizerPHA::ProgramBoard(){
|
||||||
printf("program board and channels\n");
|
|
||||||
Digitizer::ProgramBoard();
|
Digitizer::ProgramBoard();
|
||||||
|
printf("----- program PHA\n");
|
||||||
/// Set trigger propagation
|
/// Set trigger propagation
|
||||||
/// Set analog probe 1 to input
|
/// Set analog probe 1 to input
|
||||||
/// Set analog probe 2 to Tranpedoiz - Baseline
|
/// Set analog probe 2 to Tranpedoiz - Baseline
|
||||||
|
@ -30,32 +30,34 @@ int DigitizerPHA::ProgramBoard(){
|
||||||
|
|
||||||
SetRecordLength(2000);
|
SetRecordLength(2000);
|
||||||
SetPreTriggerDuration(500);
|
SetPreTriggerDuration(500);
|
||||||
SetBaselineSampling(0x11);
|
SetBaselineSampling(5);
|
||||||
SetDCOffset(0.2);
|
SetDCOffset(0.2);
|
||||||
SetInputDynamicRange(1);
|
SetInputDynamicRange(0);
|
||||||
SetPulsePolarity(0);
|
SetPulsePolarity(0);
|
||||||
|
|
||||||
SetTriggerThreshold(200);
|
SetTriggerThreshold(100);
|
||||||
SetTriggerHoldOff(480);
|
SetTriggerHoldOff(480);
|
||||||
SetTriggerSmoothingFactor(2);
|
SetTriggerSmoothingFactor(2);
|
||||||
SetTriggerOutputWidth(50);
|
SetTriggerOutputWidth(0);
|
||||||
SetInputRiseTime(96);
|
SetInputRiseTime(96);
|
||||||
|
|
||||||
SetTrapezoidRescaling(31);
|
SetTrapezoidRescaling(19);
|
||||||
SetTrapezoidRiseTime(200);
|
SetTrapezoidRiseTime(200);
|
||||||
SetTrapezoidFlatTop(50);
|
SetTrapezoidFlatTop(50);
|
||||||
SetDecayTime(10000);
|
SetDecayTime(3125);
|
||||||
SetPeakingTime(50);
|
SetPeakingTime(5);
|
||||||
SetPeakingHoldOff(1000);
|
SetPeakingHoldOff(62);
|
||||||
SetPeakSampling(2);
|
SetPeakSampling(2);
|
||||||
|
|
||||||
SetEnergyFineGain(1);
|
SetEnergyFineGain(1);
|
||||||
SetRiseTimeValidWindow(10);
|
SetRiseTimeValidWindow(0);
|
||||||
SetEventAggregation(0);
|
SetEventAggregation(0);
|
||||||
SetRollOverFlag(1);
|
SetRollOverFlag(1);
|
||||||
SetPileUpFlag(1);
|
SetPileUpFlag(1);
|
||||||
SetExtra2WordOption(2);
|
SetExtra2WordOption(2);
|
||||||
|
|
||||||
|
//WriteRegister(Register::DPP::DPPAlgorithmControl, 0xc300013);
|
||||||
|
|
||||||
ErrorMsg("PHA-ProgramBoard");
|
ErrorMsg("PHA-ProgramBoard");
|
||||||
printf("End of program board and channels\n");
|
printf("End of program board and channels\n");
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ void DigitizerPHA::SetTimeStampRecording(bool OnOff) { SetBits(Register::DPP::Bo
|
||||||
void DigitizerPHA::SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");}
|
void DigitizerPHA::SetEnergyRecording(bool OnOff) { SetBits(Register::DPP::BoardConfiguration, OnOff, 1, 19); ErrorMsg("PHA-SetEnergyRecording");}
|
||||||
void DigitizerPHA::SetVirtualProbe1(unsigned int bit){ SetBits(Register::DPP::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); }
|
void DigitizerPHA::SetVirtualProbe1(unsigned int bit){ SetBits(Register::DPP::BoardConfiguration, bit, 4, 20); ErrorMsg("PHA-SetVirtualProbe1"); }
|
||||||
|
|
||||||
void DigitizerPHA::SetTrapezoidRescaling(unsigned int rightShiftBits, int ch ){ SetBits(Register::DPP::DPPAlgorithmControl, rightShiftBits, 5, 0, ch); ErrorMsg("SetTrapezoidRescaling"); }
|
void DigitizerPHA::SetTrapezoidRescaling(unsigned int rightShiftBits, int ch){ SetBits(Register::DPP::DPPAlgorithmControl, rightShiftBits, 5, 0, ch); ErrorMsg("SetTrapezoidRescaling"); }
|
||||||
void DigitizerPHA::SetPeakSampling(unsigned int bit, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 12, ch); ErrorMsg("SetPeakSampling");}
|
void DigitizerPHA::SetPeakSampling(unsigned int bit, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 2, 12, ch); ErrorMsg("SetPeakSampling");}
|
||||||
void DigitizerPHA::SetPulsePolarity(bool PositiveIsZero, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, PositiveIsZero, 1, 16, ch); ErrorMsg("SetPulsePolarity");}
|
void DigitizerPHA::SetPulsePolarity(bool PositiveIsZero, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, PositiveIsZero, 1, 16, ch); ErrorMsg("SetPulsePolarity");}
|
||||||
void DigitizerPHA::SetBaselineSampling(unsigned int bit, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 20, ch); ErrorMsg("SetBaselineSampling"); }
|
void DigitizerPHA::SetBaselineSampling(unsigned int bit, int ch) { SetBits(Register::DPP::DPPAlgorithmControl, bit, 3, 20, ch); ErrorMsg("SetBaselineSampling"); }
|
||||||
|
@ -102,6 +104,7 @@ void DigitizerPHA::PrintBoardConfiguration(){
|
||||||
printf(" 32 28 24 20 16 12 8 4 0\n");
|
printf(" 32 28 24 20 16 12 8 4 0\n");
|
||||||
printf(" | | | | | | | | |\n");
|
printf(" | | | | | | | | |\n");
|
||||||
cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl;
|
cout <<" Board Configuration : 0b" << bitset<32>(value[0]) << endl;
|
||||||
|
printf(" : 0x%x\n", value[0]);
|
||||||
printf(" Bit[ 0] = Auto Data Flush \n");
|
printf(" Bit[ 0] = Auto Data Flush \n");
|
||||||
printf(" Bit[ 1] = Save decimated waveform \n");
|
printf(" Bit[ 1] = Save decimated waveform \n");
|
||||||
printf(" Bit[ 2] = Trigger propagation \n");
|
printf(" Bit[ 2] = Trigger propagation \n");
|
||||||
|
|
26
test.cpp
26
test.cpp
|
@ -13,19 +13,39 @@ int main(int argc, char* argv[]){
|
||||||
dig[i].OpenDigitizer(board, port, true);
|
dig[i].OpenDigitizer(board, port, true);
|
||||||
dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
|
dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
|
||||||
dig[i].SetAcqMode("list");
|
dig[i].SetAcqMode("list");
|
||||||
//dig[i].PrintACQStatue();
|
dig[i].PrintACQStatue();
|
||||||
}
|
}
|
||||||
|
|
||||||
//dig[0].PrintBoardConfiguration();
|
//dig[0].WriteRegister(Register::DPP::FrontPanelTRGOUTEnableMask, 0xFF, -1);
|
||||||
|
//dig[0].WriteRegister(Register::DPP::FrontPanelIOControl, 0x100, -1);
|
||||||
|
//dig[0].WriteRegister(Register::DPP::TriggerValidationMask, 0, -1);
|
||||||
|
|
||||||
|
//dig[0].SetTriggerThreshold(100);
|
||||||
|
|
||||||
|
//dig[0].SetBits(Register::DPP::BoardConfiguration, 0x0101, 4, 20); // TRG validation window
|
||||||
|
dig[0].PrintBoardConfiguration(); //[20:23] vitural probe
|
||||||
|
dig[0].PrintChannelSettingFromDigitizer(15);
|
||||||
|
//dig[0].ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, 13, "DPP Control 2");
|
||||||
|
//dig[0].ReadRegister(Register::DPP::AcquisitionControl, -1, "Acq control"); // [0:1]
|
||||||
|
//dig[0].ReadRegister(Register::DPP::GlobalTriggerMask, -1, "GlobalTrigger mask");
|
||||||
|
//dig[0].ReadRegister(Register::DPP::FrontPanelTRGOUTEnableMask, -1, "Front Planel Trig-OUT mask"); /// should be 0xFF
|
||||||
|
//dig[0].ReadRegister(Register::DPP::FrontPanelIOControl, -1, "Front Planel I/O control");
|
||||||
|
//dig[0].ReadRegister(Register::DPP::DisableExternalTrigger, -1, "Disable External Trigger");
|
||||||
|
//dig[0].ReadRegister(Register::DPP::TriggerValidationMask, -1, "Trigger validation Mask");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//dig[0].PrintChannelSettingFromDigitizer(15);
|
//dig[0].PrintChannelSettingFromDigitizer(15);
|
||||||
|
|
||||||
//Data * data = dig[0].data;
|
//Data * data = dig[0].data;
|
||||||
|
|
||||||
|
|
||||||
//data->AllocateMemory(dig[0].GetHandle());
|
//data->AllocateMemory(dig[0].GetHandle());
|
||||||
|
|
||||||
dig[0].StartACQ();
|
dig[0].StartACQ();
|
||||||
|
|
||||||
sleep(2);
|
sleep(5);
|
||||||
|
|
||||||
dig[0].ReadData();
|
dig[0].ReadData();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user