From 45008c21389aaa2dadb13970d81c78d3530e9c7c Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Thu, 23 May 2019 17:17:57 +0200 Subject: [PATCH] added start_delay between adc config and pulse card start; configurable via backend.conf --- machines/general.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/machines/general.cpp b/machines/general.cpp index c8d0f70..f8dab14 100644 --- a/machines/general.cpp +++ b/machines/general.cpp @@ -11,6 +11,7 @@ #include "drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.h" #include +#include #include /** @@ -29,6 +30,7 @@ @{ */ +struct timespec start_delay; class general_hardware: public hardware { @@ -90,8 +92,15 @@ public: } else USRCONF = 1; - if (!(SYSCONF | USRCONF)) + if (!(SYSCONF | USRCONF)) { + error = NULL; throw(core_exception("configuration failed!\n")); + } + + int start_delay_msec = g_key_file_get_integer(cfg_file, "PB", "start_delay_msec", &error); + ::start_delay = { start_delay_msec/1000, start_delay_msec%1000 * 1000000L}; + if (error) + g_error("%s",error->message); printf("done!\n"); /* configure ADC card */ @@ -144,6 +153,7 @@ public: g_error("%s",error->message); error = NULL; my_pts = new PTS_latched(pts_id); + // PTS 500 has 0.36 or 0.72 above 200MHz ; PTS 310 has 0.225 degrees/step my_pts->phase_step = (float) g_key_file_get_double(cfg_file, "PTS", "phase_stepsize", &error); if (error) @@ -172,6 +182,8 @@ public: the_adc->set_daq(*work_copy); else throw ADC_exception("the_adc == NULL\n"); + // ADC configured wait start_delay_msec before loading and starting pulse card + nanosleep(&::start_delay, NULL); // the pulse generator is necessary if (with_sync) { my_pulseblaster->run_pulse_program_w_sync(*work_copy, my_adc->get_sample_clock_frequency()); @@ -232,7 +244,7 @@ public: core(conf) { the_hardware = new general_hardware(); - the_name = "berta core"; + the_name = "general core"; } virtual const std::string& core_name() const {