Skip to content

Commit

Permalink
Merge pull request #107 from cescalara/solve_scurve_issues
Browse files Browse the repository at this point in the history
Fix issues with taking S-curves in the lab
  • Loading branch information
cescalara authored Oct 14, 2020
2 parents ca0acce + f143b38 commit eda7537
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 48 deletions.
57 changes: 32 additions & 25 deletions CPU/CPUsoftware/src/instrument/RunInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,35 +967,39 @@ int RunInstrument::NightOperations() {
HvpsSwitch();
}

/* reboot the Zynq */
clog << "info: " << logstream::info << "rebooting the Zynq system" << std::endl;
std::cout << "rebooting the Zynq system..." << std::endl;
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
this->Zynq.Reboot();
}

/* wait for telnet connection */
clog << "info: " << logstream::info << "waiting for boot" << std::endl;
std::cout << "waiting for boot..." << std::endl;
this->CheckStatus();
/* only reboot & reset the Zynq if not an S-curve acquisition */
if (!this->CmdLine->sc_on) {

/* reboot the Zynq */
clog << "info: " << logstream::info << "rebooting the Zynq system" << std::endl;
std::cout << "rebooting the Zynq system..." << std::endl;
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
this->Zynq.Reboot();
}

/* setup the Zynq */
clog << "info: " << logstream::info << "setting up Zynq with DAC 10 tables and trigger mask" << std::endl;
std::string usb_str(USB_MOUNTPOINT_0);
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
this->Zynq.Setup(usb_str);
}
/* wait for telnet connection */
clog << "info: " << logstream::info << "waiting for boot" << std::endl;
std::cout << "waiting for boot..." << std::endl;
this->CheckStatus();

/* set hidden pixels */
if (this->CmdLine->hide_pixel == true) {
/* setup the Zynq */
clog << "info: " << logstream::info << "setting up Zynq with DAC 10 tables and trigger mask" << std::endl;
std::string usb_str(USB_MOUNTPOINT_0);
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
this->Zynq.HidePixels();
this->Zynq.Setup(usb_str);
}
}

/* set hidden pixels */
if (this->CmdLine->hide_pixel == true) {
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
this->Zynq.HidePixels();
}
}
}

return 0;
}

Expand Down Expand Up @@ -1095,8 +1099,11 @@ void RunInstrument::Start() {
this->MonitorInstrument();

/* launch background process to run status checker */
this->StatusChecker();

/* only if not an S-curve acquisition */
if (!this->CmdLine->sc_on) {
this->StatusChecker();
}

/* enable signal handling */
signal(SIGINT, SignalHandler);

Expand Down
52 changes: 35 additions & 17 deletions CPU/CPUsoftware/src/operations/DataAcquisition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,23 +582,28 @@ void DataAcquisition::FtpPoll(bool monitor) {
const char * ftp_cmd = "";
std::string ftp_cmd_str;

std::stringstream conv1;
std::stringstream conv2;

/* clear the server */
clog << "info: " << logstream::info << "clearing old files from FTP server" << std::endl;
if (monitor) {

/* build the command */
conv1 << "lftp -u minieusouser,minieusopass -e "
<< "\"set ftp:passive-mode off;mrm *;quit\""
<< " 192.168.7.10" << "> /dev/null 2>&1" << std::endl;
std::stringstream conv1;

/* clear the server */
clog << "info: " << logstream::info << "clearing old files from FTP server" << std::endl;

/* build the command */
conv1 << "lftp -u minieusouser,minieusopass -e "
<< "\"set ftp:passive-mode off;mrm *;quit\""
<< " 192.168.7.10" << "> /dev/null 2>&1" << std::endl;

/* convert stringstream to char * */
ftp_clear_str = conv1.str();
ftp_clear = ftp_clear_str.c_str();
/* convert stringstream to char * */
ftp_clear_str = conv1.str();
ftp_clear = ftp_clear_str.c_str();

output = CpuTools::CommandToStr(ftp_clear);

output = CpuTools::CommandToStr(ftp_clear);

}

/* start FTP polling */
clog << "info: " << logstream::info << "starting FTP server polling" << std::endl;

Expand Down Expand Up @@ -1002,19 +1007,32 @@ int DataAcquisition::CollectSc(ZynqManager * Zynq, std::shared_ptr<Config> Confi
std::unique_lock<std::mutex> lock(Zynq->m_zynq);
Zynq->Scurve(ConfigOut->scurve_start, ConfigOut->scurve_step, ConfigOut->scurve_stop, ConfigOut->scurve_acc);
}
/* FTP polling */
std::thread ftp_poll (&DataAcquisition::FtpPoll, this, false);

// Debug
clog << "info: " << logstream::info << "launching ProcessInocmingData() from CollectSc()" << std::endl;

/* collect the data */
std::thread collect_data (&DataAcquisition::ProcessIncomingData, this, ConfigOut, CmdLine, main_thread, true);

// Debug
clog << "info: " << logstream::info << "launching FtpPoll() from CollectSc()" << std::endl;
std::cout << "Now polling FTP server, please wait..." << std::endl;

/* FTP polling */
std::thread ftp_poll (&DataAcquisition::FtpPoll, this, false);
ftp_poll.join();

clog << "info: " << logstream::info << "signalling Scurve completion to ProcessIncomingData()" << std::endl;
std::cout << "Signalling Scurve completion..." << std::endl;

/* signal that scurve is done */
this->SignalScurveDone();

clog << "info: " << logstream::info << "waiting for ProcessIncomingData() to join" << std::endl;
std::cout << "Waiting for data collection to complete..." << std::endl;

/* join threads */
/* join remaining thread */
collect_data.join();
ftp_poll.join();

#endif /* __APPLE__ */
return 0;
Expand Down
4 changes: 3 additions & 1 deletion CPU/CPUsoftware/src/subsystems/ZynqManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,13 @@ bool ZynqManager::CheckScurve(int sockfd) {
size_t noacq_found = status_string.find("GatheringInProgress=0");
if (noacq_found != std::string::npos) {

clog << "info: " << logstream::info << "update ZynqManager::CheckScurve(), Scurve completed!" << std::endl;

/* scurve gathering is done */
scurve_status = true;
}
else {
clog << "error: " << logstream::error << "bad socket in ZynqManager::CheckScurve()" << std::endl;
clog << "info: " << logstream::info << "update ZynqManager::CheckScurve(), Scurve not yet complete..." << std::endl;

}

Expand Down
6 changes: 6 additions & 0 deletions CPU/dac_setting/dac10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
604 604 596 612 628 628
604 604 626 620 620 628
612 612 596 620 596 588
612 612 596 620 612 596
634 636 636 620 636 596
634 636 596 660 636 636
4 changes: 2 additions & 2 deletions docs/configuration_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The following parameters can be set in the configuration file:
* ``SCURVE_START``: The DAC pulse threshold at which to start S-curve acquisition (an integer between 0 and 1023)
* ``SCURVE_STEP``: The DAC step to take in sweeping the pulse threshold in an S-curve (an integer between 0 and 1023)
* ``SCURVE_STOP``: The DAC pulse threshold at which to stop S-curve acquisition (an integer between 0 and 1023)
* ``SCURVE_ACC``: The number of frames to average over during each step of the S-curve acquisition (an integer between 1 aand 999999)
* ``DAC_LEVEL``: The DAC pulse threshold to use during standard data acquisition - usually set by looking at S-curves (an integer between 0 and 1023)
* ``SCURVE_ACC``: The number of frames to average over during each step of the S-curve acquisition (an integer between 1 and 999999)
* ``DAC_LEVEL``: The DAC pulse threshold to use during standard data acquisition - usually set by looking at S-curves (an integer between 0 and 1023) **NB: if you want the DAC level to be set individually for all PMTs by the dac10.txt table, set this parameter to -99**
* ``N1``: Number of level 1 (D1) data packets to be read out by the Zynq (an integer between 1 and 8)
* ``N2``: Number of level 2 (D2) data packets to be read out by the Zynq (an integer between 1 and 8)
* ``L2_N_BG``: Level 2 trigger - number of times above background level to set threshold (an integer between 2 and max value if unsigned int)
Expand Down
11 changes: 10 additions & 1 deletion docs/usage/functionality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ General
* ``mecontrol -help`` show a list of all the command line options
* ``mecontrol -ver`` show the version info
* ``mecontrol -db`` run a debug program for diagnostic tests of all subsystems

**NB: the use of command line arguments will always override the corresponding values specified in the configuration file**. This is beacsue command line use is intended for testing in the lab, whereas the configuration file specifies these values more robustly for automated use on the ISS.


Control of the high voltage (HV)
Expand Down Expand Up @@ -34,13 +36,20 @@ The CPU controls the HV sent to the PMTs via the Zynq board.
* the flag ``-dv <X>`` sets the dynode voltage to X, where X is the DAC between 0 and 4096
* the flag ``-dvr <X>`` sets the dynode voltage to X, where X is the voltage in VOLTS between 0 and 1100
* the conversion between this number ``<X>`` and a voltage is ``<X>/4096 * 2.44 * 466``, ie. ``DAC/maxDAC * maxDAC_voltage * 466``
* the flag ``-asicdac <Y>`` sets the ASIC dac level, or the point in an S-curve that we want to use to acquire data (should be in the S-curve plateau)
* the flag ``-asicdac <Y>`` sets the ASIC dac level, or the point in an S-curve that we want to use to acquire data (should be in the S-curve plateau), this will override the ``DAC_LEVEL`` set in the configuration file
* the ``-asicdac`` flag was previously ``-hvdac`` but this was changed to avoid confusion, however, for the sake of compatibility, ``-hvdac`` can still be used with identical functionality
* if these flags are not supplied, their default values are used from the configuration file in ``CPUsoftware/config``

* To check the current status, use ``mecontrol -check_status``
* If an acquisition with HV is interrupted using ``CTRL-C``, the HV will be switched off automatically

* Use of ``dac10.txt`` to set individual ``-asicdac`` values for each PMT

* The ``-asicdac`` flag or ``DAC_LEVEL`` entry in the configuration file can be used to set the same DAC level for all PMTS

* To set individual values, the ``dac10.txt`` file can be placed in ``automated_boot/dac10.txt`` which the software looks for under ``USB_MOUNTPOINT_0`` set in ``UsbManager.h``

* The format of this file is a 6x6 grid of numbers separated by single spaces and newlines - an example can be found in ``CPU/dac_setting/dac10.txt`` in the main code repo

Control of the low voltage power supply (LVPS)
----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions minieuso_data_format/minieuso_data_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* software definitions
*/

#define VERSION 8.8
#define VERSION_DATE_STRING "09/03/2020"
#define VERSION 9.5
#define VERSION_DATE_STRING "13/10/2020"

/*
* instrument definitions
Expand Down

0 comments on commit eda7537

Please sign in to comment.