diff --git a/.gitignore b/.gitignore index 1737874..8b50285 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ software/drscl/DRSOsc.app -drs_exam -drs_exam_multi -drscl -drsosc +software/drscl/drs_exam +software/drscl/drs_exam_multi +software/drscl/drscl +software/drsosc/drsosc firmware/3s400/iseconfig/ firmware/3s400/xst/ firmware/3s400/_xmsgs/ diff --git a/software/drscl/drs_exam_2048.cpp b/software/drscl/drs_exam_2048.cpp new file mode 100644 index 0000000..fb6fead --- /dev/null +++ b/software/drscl/drs_exam_2048.cpp @@ -0,0 +1,186 @@ +/********************************************************************\ + + Name: drs_exam_2048.cpp + Created by: Stefan Ritt + + Contents: Simple example application to read out a DRS4 + evaluation board in 2048-bin configuration (which + needs a hardware modification on the board) + + $Id: drs_exam.cpp 21308 2014-04-11 14:50:16Z ritt $ + +\********************************************************************/ + +#include + +#ifdef _MSC_VER + +#include + +#elif defined(OS_LINUX) + +#define O_BINARY 0 + +#include +#include +#include +#include + +#define DIR_SEPARATOR '/' + +#endif + +#include +#include +#include + +#include "strlcpy.h" +#include "DRS.h" + +#ifdef _MSC_VER +#pragma warning(disable:4996) +#else +# include +# include +inline void Sleep(useconds_t x) +{ + usleep(x * 1000); +} +#endif + +/*------------------------------------------------------------------*/ + +int main() +{ + int i, j, nBoards; + DRS *drs; + DRSBoard *b; + float time_array[8][2048]; + float wave_array[8][2048]; + FILE *f; + + /* do initial scan */ + drs = new DRS(); + + /* show any found board(s) */ + for (i=0 ; iGetNumberOfBoards() ; i++) { + b = drs->GetBoard(i); + printf("Found DRS4 evaluation board, serial #%d, firmware revision %d\n", + b->GetBoardSerialNumber(), b->GetFirmwareVersion()); + } + + /* exit if no board found */ + nBoards = drs->GetNumberOfBoards(); + if (nBoards == 0) { + printf("No DRS4 evaluation board found\n"); + return 0; + } + + /* continue working with first board only */ + b = drs->GetBoard(0); + + /* initialize board */ + b->Init(); + + /* set sampling frequency */ + b->SetFrequency(5, true); + + /* enable transparent mode needed for analog trigger */ + b->SetTranspMode(1); + + /* set input range to -0.5V ... +0.5V */ + b->SetInputRange(0); + + /* use following line to set range to 0..1V */ + //b->SetInputRange(0.5); + + /* set 2048-bin mode */ + if (!b->Is2048ModeCapable()) { + printf("Board is not configured for 2048-bin mode\n"); + return 0; + } + Sleep(10); // wait until evaluation board is ready + b->SetChannelConfig(0, 8, 4); + + /* use following line to turn on the internal 100 MHz clock connected to all channels */ + //b->EnableTcal(1); + + /* use following lines to enable hardware trigger on CH1 at 50 mV positive edge */ + if (b->GetBoardType() >= 8) { // Evaluaiton Board V4&5 + b->EnableTrigger(1, 0); // enable hardware trigger + b->SetTriggerConfig(1<<0); // set CH1 as source + } else if (b->GetBoardType() == 7) { // Evaluation Board V3 + b->EnableTrigger(0, 1); // lemo off, analog trigger on + b->SetTriggerConfig(1); // use CH1 as source + } + b->SetTriggerLevel(0.05); // 0.05 V + b->SetTriggerPolarity(false); // positive edge + + /* use following lines to set individual trigger elvels */ + //b->SetIndividualTriggerLevel(1, 0.1); + //b->SetIndividualTriggerLevel(2, 0.2); + //b->SetIndividualTriggerLevel(3, 0.3); + //b->SetIndividualTriggerLevel(4, 0.4); + //b->SetTriggerSource(15); + + b->SetTriggerDelayNs(0); // zero ns trigger delay + + /* use following lines to enable the external trigger */ + //if (b->GetBoardType() >= 8) { // Evaluaiton Board V4&5 + // b->EnableTrigger(1, 0); // enable hardware trigger + // b->SetTriggerConfig(1<<4); // set external trigger as source + //} else { // Evaluation Board V3 + // b->EnableTrigger(1, 0); // lemo on, analog trigger off + //} + + /* open file to save waveforms */ + f = fopen("data.txt", "w"); + if (f == NULL) { + perror("ERROR: Cannot open file \"data.txt\""); + return 1; + } + + /* repeat ten times */ + for (j=0 ; j<10 ; j++) { + + /* start board (activate domino wave) */ + b->StartDomino(); + + /* wait for trigger */ + printf("Waiting for trigger..."); + + fflush(stdout); + while (b->IsBusy()); + + /* read all waveforms */ + b->TransferWaves(0, 8); + + /* read time (X) array of first channel in ns */ + b->GetTime(0, 0, b->GetTriggerCell(0), time_array[0]); + + /* decode waveform (Y) array of first channel in mV */ + b->GetWave(0, 0, wave_array[0], true, b->GetTriggerCell(0), b->GetStopWSR(0)); + + /* read time (X) array of second channel in ns + Note: On the evaluation board input #1 is connected to channel 0 and 1 of + the DRS chip, input #2 is connected to channel 2 and 3 and so on. So to + get the input #2 we have to read DRS channel #2, not #1. */ + b->GetTime(0, 2, b->GetTriggerCell(0), time_array[1]); + + /* decode waveform (Y) array of second channel in mV */ + b->GetWave(0, 2, wave_array[1]); + + /* Save waveform: X=time_array[i], Yn=wave_array[n][i] */ + fprintf(f, "Event #%d ----------------------\n t1[ns] u1[mV] t2[ns] u2[mV]\n", j); + for (i=0 ; iGetChannelDepth(); i++) + fprintf(f, "%7.3f %7.1f %7.3f %7.1f\n", time_array[0][i], wave_array[0][i], time_array[1][i], wave_array[1][i]); + + /* print some progress indication */ + printf("\rEvent #%d read successfully\n", j); + } + + fclose(f); + + /* delete DRS object -> close USB connection */ + delete drs; +} diff --git a/software/drsosc/DOFrame.h b/software/drsosc/DOFrame.h index 1990aac..557c142 100644 --- a/software/drsosc/DOFrame.h +++ b/software/drsosc/DOFrame.h @@ -110,7 +110,7 @@ public: bool GetMultiBoard() { return m_multiBoard; } void SetSource(int board, int firstChannel, int chnSection); void SetRefclk(int board, bool flag); - bool GetRefclk() { return m_refClk > 0; } + bool GetRefclk(int board) { return m_refClk[board]; } void SetRange(double range){ m_range[m_board] = range; } double GetRange() { return m_range[m_board]; } void SetSpikeRemoval(bool flag) { m_spikeRemoval = flag; m_osci->SetSpikeRemoval(flag); } diff --git a/software/drsosc/drsosc.xcodeproj/project.pbxproj b/software/drsosc/drsosc.xcodeproj/project.pbxproj index dfdbac2..32b394c 100644 --- a/software/drsosc/drsosc.xcodeproj/project.pbxproj +++ b/software/drsosc/drsosc.xcodeproj/project.pbxproj @@ -241,7 +241,7 @@ D54FC049142777CD00A7A6B0 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = PSI; TargetAttributes = { D54FC051142777CE00A7A6B0 = { @@ -318,12 +318,18 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -359,12 +365,18 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;