fix RecordLength bug for QDC. Can't 100% trust CAEN manual
This commit is contained in:
parent
00a16ffc2e
commit
bebff94e62
|
@ -47,6 +47,7 @@ void Digitizer::Initalization(){
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
AcqRun = false;
|
AcqRun = false;
|
||||||
isDummy = true;
|
isDummy = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::Reset(){
|
void Digitizer::Reset(){
|
||||||
|
@ -64,7 +65,7 @@ void Digitizer::Reset(){
|
||||||
|
|
||||||
void Digitizer::PrintBoard (){
|
void Digitizer::PrintBoard (){
|
||||||
printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
|
printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link");
|
||||||
printf(" Sampling rate : %.0f MHz = %.1f ns \n", 1000/tick2ns, tick2ns);
|
printf(" Sampling rate : %.1f MHz = %.1f ns \n", 1000./tick2ns, tick2ns);
|
||||||
printf("No. of Input Channels : %d \n", NumInputCh);
|
printf("No. of Input Channels : %d \n", NumInputCh);
|
||||||
printf(" No. of Reg Channels : %d, mask : 0x%X\n", NumRegChannel, regChannelMask);
|
printf(" No. of Reg Channels : %d, mask : 0x%X\n", NumRegChannel, regChannelMask);
|
||||||
printf(" SerialNumber :\e[1m\e[33m %d\e[0m\n", BoardInfo.SerialNumber);
|
printf(" SerialNumber :\e[1m\e[33m %d\e[0m\n", BoardInfo.SerialNumber);
|
||||||
|
@ -436,7 +437,8 @@ int Digitizer::ProgramBoard_QDC(){
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
//WriteRegister(DPP::QDC::NumberEventsPerAggregate, 0x10, -1);
|
//WriteRegister(DPP::QDC::NumberEventsPerAggregate, 0x10, -1);
|
||||||
WriteRegister(DPP::QDC::RecordLength_W, 16, -1); // 128 sample = 2048 ns
|
WriteRegister(DPP::QDC::RecordLength, 16, -1); // 128 sample = 2048 ns
|
||||||
|
|
||||||
WriteRegister(DPP::QDC::PreTrigger, 60, -1); // at 60 sample = 960 ns
|
WriteRegister(DPP::QDC::PreTrigger, 60, -1); // at 60 sample = 960 ns
|
||||||
|
|
||||||
WriteRegister(DPP::QDC::GateWidth, 100/16, -1);
|
WriteRegister(DPP::QDC::GateWidth, 100/16, -1);
|
||||||
|
@ -494,7 +496,9 @@ void Digitizer::StartACQ(){
|
||||||
// ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, 0, 0); // Auto set
|
// ret |= CAEN_DGTZ_SetDPPEventAggregation(handle, 0, 0); // Auto set
|
||||||
|
|
||||||
unsigned int bufferSize = CalByteForBufferCAEN();
|
unsigned int bufferSize = CalByteForBufferCAEN();
|
||||||
if( bufferSize > 160 * 1024 * 1024 ) printf("============= buffer size bigger than 160 MB (%u)\n", bufferSize );
|
// unsigned int bufferSize = 200 * 1024 * 1024;
|
||||||
|
// if( DPPType == DPPTypeCode::DPP_QDC_CODE ) bufferSize = 500 * 1024 * 1024;
|
||||||
|
// if( bufferSize > 160 * 1024 * 1024 ) printf("============= buffer size bigger than 160 MB (%u)\n", bufferSize );
|
||||||
|
|
||||||
data->AllocateMemory(bufferSize);
|
data->AllocateMemory(bufferSize);
|
||||||
|
|
||||||
|
@ -650,7 +654,7 @@ int Digitizer::ReadData(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadACQStatus();
|
// ReadACQStatus();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -678,7 +682,7 @@ void Digitizer::ReadAndPrintACQStatue(){
|
||||||
//===========================================================
|
//===========================================================
|
||||||
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
|
void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){
|
||||||
if( softwareDisable ) return;
|
if( softwareDisable ) return;
|
||||||
printf("%30s[0x%04X](digi-%d,ch-%02d) [0x%04X]: 0x%08X \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),GetSerialNumber(), ch, registerAddress.ActualAddress(ch), value);
|
printf("WRITE|%30s[0x%04X](digi-%d,ch-%02d) [0x%04X]: 0x%08X \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),GetSerialNumber(), ch, registerAddress.ActualAddress(ch), value);
|
||||||
|
|
||||||
if( !isConnected ) {
|
if( !isConnected ) {
|
||||||
//SetSettingToMemory(registerAddress, value, ch); //TODO should the binary setting be edited offline?
|
//SetSettingToMemory(registerAddress, value, ch); //TODO should the binary setting be edited offline?
|
||||||
|
@ -720,6 +724,7 @@ uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool is
|
||||||
if( softwareDisable ) return 0;
|
if( softwareDisable ) return 0;
|
||||||
if( !isConnected ) return 0;
|
if( !isConnected ) return 0;
|
||||||
if( registerAddress.GetRWType() == RW::WriteONLY ) return 0;
|
if( registerAddress.GetRWType() == RW::WriteONLY ) return 0;
|
||||||
|
// if( registerAddress == DPP::QDC::RecordLength_W ) return 0;
|
||||||
|
|
||||||
ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), &returnData);
|
ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), &returnData);
|
||||||
|
|
||||||
|
@ -732,8 +737,8 @@ uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool is
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::hex << registerAddress.ActualAddress(ch);
|
ss << std::hex << registerAddress.ActualAddress(ch);
|
||||||
|
|
||||||
ErrorMsg("ReadRegister:0x" + ss.str() + "(" + registerAddress.GetName() + ")");
|
ErrorMsg("Register:0x" + ss.str() + "(" + registerAddress.GetName() + ")");
|
||||||
if( str != "" ) printf("%s : 0x%04X(0x%04X) is 0x%08X \n", str.c_str(),
|
if( !str.empty() ) printf("READ|%s : 0x%04X(0x%04X) is 0x%08X \n", str.c_str(),
|
||||||
registerAddress.ActualAddress(ch), registerAddress.GetAddress(), returnData);
|
registerAddress.ActualAddress(ch), registerAddress.GetAddress(), returnData);
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
|
@ -744,15 +749,15 @@ uint32_t Digitizer::PrintRegister(uint32_t address, std::string msg){
|
||||||
printf("------------ %s = 0x%X \n", msg.c_str(), address);
|
printf("------------ %s = 0x%X \n", msg.c_str(), address);
|
||||||
printf("----------------------------------------------------\e[0m\n");
|
printf("----------------------------------------------------\e[0m\n");
|
||||||
|
|
||||||
uint32_t * value = new uint32_t[1];
|
uint32_t value;
|
||||||
CAEN_DGTZ_ReadRegister(handle, address, value);
|
CAEN_DGTZ_ReadRegister(handle, address, &value);
|
||||||
printf(" %*s 32 28 24 20 16 12 8 4 0\n", (int) msg.length(), "");
|
printf(" %*s 32 28 24 20 16 12 8 4 0\n", (int) msg.length(), "");
|
||||||
printf(" %*s | | | | | | | | |\n", (int) msg.length(), "");
|
printf(" %*s | | | | | | | | |\n", (int) msg.length(), "");
|
||||||
printf(" %*s", (int) msg.length(), "");
|
printf(" %*s", (int) msg.length(), "");
|
||||||
std::cout << " : 0b" << std::bitset<32>(value[0]) << std::endl;
|
std::cout << " : 0b" << std::bitset<32>(value) << std::endl;
|
||||||
printf(" %*s : 0x%X\n", (int) msg.length(), msg.c_str(), value[0]);
|
printf(" %*s : 0x%08X = %u\n", (int) msg.length(), msg.c_str(), value, value);
|
||||||
|
|
||||||
return value[0];
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================== setting file IO
|
//========================================== setting file IO
|
||||||
|
@ -842,6 +847,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
|
||||||
if( RegisterBoardList_QDC[p].GetRWType() == RW::WriteONLY) continue;
|
if( RegisterBoardList_QDC[p].GetRWType() == RW::WriteONLY) continue;
|
||||||
ReadRegister(RegisterBoardList_QDC[p]);
|
ReadRegister(RegisterBoardList_QDC[p]);
|
||||||
}
|
}
|
||||||
|
|
||||||
regChannelMask = GetSettingFromMemory(DPP::QDC::GroupEnableMask);
|
regChannelMask = GetSettingFromMemory(DPP::QDC::GroupEnableMask);
|
||||||
|
|
||||||
for( int ch = 0; ch < GetNumRegChannels(); ch ++){
|
for( int ch = 0; ch < GetNumRegChannels(); ch ++){
|
||||||
|
|
|
@ -106,7 +106,10 @@ class Digitizer{
|
||||||
Data * GetData() const {return data;}
|
Data * GetData() const {return data;}
|
||||||
uint32_t GetACQStatusFromMemory() const {return acqStatus;}
|
uint32_t GetACQStatusFromMemory() const {return acqStatus;}
|
||||||
void ReadAndPrintACQStatue();
|
void ReadAndPrintACQStatue();
|
||||||
void ReadACQStatus() { acqStatus = ReadRegister(DPP::AcquisitionStatus_R); }
|
void ReadACQStatus() {
|
||||||
|
// printf("%s\n", __func__);
|
||||||
|
acqStatus = ReadRegister(DPP::AcquisitionStatus_R);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int CalByteForBuffer(bool verbose = false);
|
unsigned int CalByteForBuffer(bool verbose = false);
|
||||||
unsigned int CalByteForBufferCAEN();
|
unsigned int CalByteForBufferCAEN();
|
||||||
|
|
|
@ -70,6 +70,14 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_REALTIME, &t1);
|
||||||
|
if( t1.tv_sec - ta.tv_sec > 2 ){
|
||||||
|
digiMTX[ID].lock();
|
||||||
|
digi->ReadACQStatus();
|
||||||
|
digiMTX[ID].unlock();
|
||||||
|
ta = t1;
|
||||||
|
}
|
||||||
|
|
||||||
if( isSaveData && !stop ) {
|
if( isSaveData && !stop ) {
|
||||||
clock_gettime(CLOCK_REALTIME, &tb);
|
clock_gettime(CLOCK_REALTIME, &tb);
|
||||||
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
||||||
|
|
|
@ -3117,6 +3117,7 @@ void DigiSettingsPanel::UpdateReadOutStatus(uint32_t status){
|
||||||
|
|
||||||
void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
|
void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
|
||||||
|
|
||||||
|
printf("%s\n", __func__);
|
||||||
//*========================================
|
//*========================================
|
||||||
uint32_t AcqStatus = digi[ID]->ReadRegister(DPP::AcquisitionStatus_R);
|
uint32_t AcqStatus = digi[ID]->ReadRegister(DPP::AcquisitionStatus_R);
|
||||||
UpdateACQStatus(AcqStatus);
|
UpdateACQStatus(AcqStatus);
|
||||||
|
|
|
@ -1148,6 +1148,7 @@ void MainWindow::StopACQ(){
|
||||||
if( chkSaveData->isChecked() ) digi[i]->GetData()->CloseSaveFile();
|
if( chkSaveData->isChecked() ) digi[i]->GetData()->CloseSaveFile();
|
||||||
LogMsg("Digi-" + QString::number(digi[i]->GetSerialNumber()) + " ACQ is stopped." );
|
LogMsg("Digi-" + QString::number(digi[i]->GetSerialNumber()) + " ACQ is stopped." );
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
digi[i]->ReadACQStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( scalarThread->isRunning()){
|
if( scalarThread->isRunning()){
|
||||||
|
|
|
@ -787,7 +787,7 @@ namespace DPP {
|
||||||
|
|
||||||
namespace QDC { // Register already grouped in channel. and there no control for indiviual channel except the Fine DC offset and threshold, so it is like no group
|
namespace QDC { // Register already grouped in channel. and there no control for indiviual channel except the Fine DC offset and threshold, so it is like no group
|
||||||
const Reg NumberEventsPerAggregate ("Number of Events per Aggregate", 0x1020, RW::ReadWrite, false, 0x3FF, -1); /// R/W
|
const Reg NumberEventsPerAggregate ("Number of Events per Aggregate", 0x1020, RW::ReadWrite, false, 0x3FF, -1); /// R/W
|
||||||
const Reg RecordLength ("Record Length_R" , 0x1024, RW::ReadWrite, false, 0x1FFF, 8); /// R/W
|
const Reg RecordLength ("Record Length" , 0x1024, RW::ReadWrite, false, 0x1FFF, 8); /// R
|
||||||
const Reg GateWidth ("GateWidth" , 0x1030, RW::ReadWrite, false, 0xFFF, 1); /// R/W
|
const Reg GateWidth ("GateWidth" , 0x1030, RW::ReadWrite, false, 0xFFF, 1); /// R/W
|
||||||
const Reg GateOffset ("GateOfset" , 0x1034, RW::ReadWrite, false, 0xFF, 1); /// R/W
|
const Reg GateOffset ("GateOfset" , 0x1034, RW::ReadWrite, false, 0xFF, 1); /// R/W
|
||||||
const Reg FixedBaseline ("FixedBaseline" , 0x1038, RW::ReadWrite, false, 0xFFF, -1); /// R/W
|
const Reg FixedBaseline ("FixedBaseline" , 0x1038, RW::ReadWrite, false, 0xFFF, -1); /// R/W
|
||||||
|
@ -811,9 +811,11 @@ namespace DPP {
|
||||||
const Reg TriggerThreshold_sub6 ("Trigger Threshold sub6" , 0x10E8, RW::ReadWrite, false, 0xFFF, -1); /// R/W
|
const Reg TriggerThreshold_sub6 ("Trigger Threshold sub6" , 0x10E8, RW::ReadWrite, false, 0xFFF, -1); /// R/W
|
||||||
const Reg TriggerThreshold_sub7 ("Trigger Threshold sub7" , 0x10EC, RW::ReadWrite, false, 0xFFF, -1); /// R/W
|
const Reg TriggerThreshold_sub7 ("Trigger Threshold sub7" , 0x10EC, RW::ReadWrite, false, 0xFFF, -1); /// R/W
|
||||||
|
|
||||||
const Reg RecordLength_W ("Record Length_W" , 0x8024, RW::WriteONLY, false, 0x1FFF, 8); /// /W
|
|
||||||
const Reg GroupEnableMask ("Group Enable Mask" , 0x8120, RW::ReadWrite, false, 0xFF, -1); /// R/W
|
const Reg GroupEnableMask ("Group Enable Mask" , 0x8120, RW::ReadWrite, false, 0xFF, -1); /// R/W
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Bit_DPPAlgorithmControl {
|
namespace Bit_DPPAlgorithmControl {
|
||||||
const std::pair<unsigned short, unsigned short> ChargeSensitivity = {3, 0} ; /// length, smallest pos
|
const std::pair<unsigned short, unsigned short> ChargeSensitivity = {3, 0} ; /// length, smallest pos
|
||||||
const std::pair<unsigned short, unsigned short> InternalTestPulse = {1, 4};
|
const std::pair<unsigned short, unsigned short> InternalTestPulse = {1, 4};
|
||||||
|
@ -1025,7 +1027,7 @@ const std::vector<Reg> RegisterBoardList_QDC = {
|
||||||
DPP::BoardConfiguration ,
|
DPP::BoardConfiguration ,
|
||||||
DPP::AggregateOrganization,
|
DPP::AggregateOrganization,
|
||||||
DPP::QDC::NumberEventsPerAggregate,
|
DPP::QDC::NumberEventsPerAggregate,
|
||||||
DPP::QDC::RecordLength_W,
|
// DPP::QDC::RecordLength_W,
|
||||||
DPP::AcquisitionControl,
|
DPP::AcquisitionControl,
|
||||||
DPP::AcquisitionStatus_R,
|
DPP::AcquisitionStatus_R,
|
||||||
DPP::SoftwareTrigger_W,
|
DPP::SoftwareTrigger_W,
|
||||||
|
|
10
Scope.cpp
10
Scope.cpp
|
@ -371,9 +371,9 @@ void Scope::StartScope(){
|
||||||
digi[iDigi]->WriteRegister(DPP::SoftwareClear_W, 1);
|
digi[iDigi]->WriteRegister(DPP::SoftwareClear_W, 1);
|
||||||
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1);
|
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1);
|
||||||
|
|
||||||
AggPerRead[iDigi] = digi[iDigi]->GetSettingFromMemory(DPP::MaxAggregatePerBlockTransfer);
|
//AggPerRead[iDigi] = digi[iDigi]->GetSettingFromMemory(DPP::MaxAggregatePerBlockTransfer);
|
||||||
SendLogMsg("Set Events/Agg to 1 for scope, it was " + QString::number(AggPerRead[iDigi]) + ".");
|
//SendLogMsg("Set Agg/Read to 1 for scope, it was " + QString::number(AggPerRead[iDigi]) + ".");
|
||||||
digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, 1);
|
//digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, 1);
|
||||||
|
|
||||||
readDataThread[iDigi]->SetScopeMode(true);
|
readDataThread[iDigi]->SetScopeMode(true);
|
||||||
readDataThread[iDigi]->SetSaveData(false);
|
readDataThread[iDigi]->SetSaveData(false);
|
||||||
|
@ -431,7 +431,7 @@ void Scope::StopScope(){
|
||||||
digiMTX[iDigi].unlock();
|
digiMTX[iDigi].unlock();
|
||||||
|
|
||||||
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1);
|
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1);
|
||||||
digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, AggPerRead[iDigi]);
|
//digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, AggPerRead[iDigi]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,7 +883,7 @@ void Scope::SetUpPanel_QDC() {
|
||||||
|
|
||||||
int rowID = 0;
|
int rowID = 0;
|
||||||
|
|
||||||
SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::QDC::RecordLength_W);
|
SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::QDC::RecordLength);
|
||||||
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns] ", rowID, 2, DPP::QDC::PreTrigger);
|
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns] ", rowID, 2, DPP::QDC::PreTrigger);
|
||||||
SetUpSpinBox(sbDCOffset, "DC offset [%] ", rowID, 4, DPP::QDC::DCOffset);
|
SetUpSpinBox(sbDCOffset, "DC offset [%] ", rowID, 4, DPP::QDC::DCOffset);
|
||||||
sbDCOffset->setDecimals(2);
|
sbDCOffset->setDecimals(2);
|
||||||
|
|
2
macro.h
2
macro.h
|
@ -2,7 +2,7 @@
|
||||||
#define MACRO_H
|
#define MACRO_H
|
||||||
|
|
||||||
#define MaxNPorts 4 //for optical link
|
#define MaxNPorts 4 //for optical link
|
||||||
#define MaxNBoards 8 //for both optical link and usb
|
#define MaxNBoards 4 //for both optical link and usb
|
||||||
|
|
||||||
#define MaxNDigitizer MaxNPorts * MaxNBoards
|
#define MaxNDigitizer MaxNPorts * MaxNBoards
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user