Skip to content

Commit

Permalink
Merge pull request #64 from cescalara/add-eusota-trigger
Browse files Browse the repository at this point in the history
Add eusota trigger
  • Loading branch information
cescalara authored May 6, 2019
2 parents ec23fbb + 1627130 commit 9b1e1bb
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 53 deletions.
18 changes: 9 additions & 9 deletions CPU/CPUsoftware/src/instrument/RunInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int RunInstrument::DebugMode() {
this->Cam.usb_num_storage_dev = num_usb_storage;
std::cout << std::endl;

#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG !=1
std::cout << "LVPS" << std::endl;
std::cout << "switching on all subsystems... " << std::endl;
std::cout << "cameras ON " << std::endl;
Expand Down Expand Up @@ -414,7 +414,7 @@ int RunInstrument::CheckSystems() {


std::cout << "STARTING INSTRUMENT" << std::endl;
#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
/* first power off all systems, for a clean start */
this->Lvps.SwitchOff(LvpsManager::CAMERAS);
this->Lvps.SwitchOff(LvpsManager::HK);
Expand Down Expand Up @@ -711,7 +711,7 @@ int RunInstrument::RunningStatusCheck() {
std::cout << std::endl;
std::cout << "STATUS UPDATE" << std::endl;

#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
/* telnet connection and HV */
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
Expand Down Expand Up @@ -759,7 +759,7 @@ int RunInstrument::Acquisition() {
std::cout << "starting acquisition run..." <<std::endl;
clog << "info: " << logstream::info << "starting acquisition run" << std::endl;

#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG !=1

/* clear the FTP server */
CpuTools::ClearFolder(DATA_DIR);
Expand Down Expand Up @@ -812,9 +812,9 @@ int RunInstrument::Acquisition() {
int RunInstrument::NightOperations() {

/* check scurve not already completed */
if (this->Daq.IsScurveDone()) {
if (this->Daq.IsScurveDone()) {
return 0;
}
}

clog << "info: " << logstream::info << "entering NIGHT mode" << std::endl;
std::cout << "entering NIGHT mode..." << std::endl;
Expand Down Expand Up @@ -892,7 +892,7 @@ void RunInstrument::Stop() {
*/
void RunInstrument::Start() {

#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
/* check for execute-and-exit commands */
if (this->CmdLine->lvps_on) {
LvpsSwitch();
Expand All @@ -911,7 +911,7 @@ void RunInstrument::Start() {
}


#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
/* check for execute-and-exit commands which require config */
if (this->CmdLine->hvps_switch) {
HvpsSwitch();
Expand All @@ -926,7 +926,7 @@ void RunInstrument::Start() {
/* check systems and operational mode */
this->CheckSystems();

#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
{
std::unique_lock<std::mutex> lock(this->Zynq.m_zynq);
if (!this->Zynq.telnet_connected) {
Expand Down
7 changes: 3 additions & 4 deletions CPU/CPUsoftware/src/operations/DataAcquisition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ int DataAcquisition::CollectData(ZynqManager * Zynq, std::shared_ptr<Config> Con

long unsigned int main_thread = pthread_self();

#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
/* FTP polling */
std::thread ftp_poll (&DataAcquisition::FtpPoll, this, true);

Expand Down Expand Up @@ -1073,7 +1073,7 @@ int DataAcquisition::CollectData(ZynqManager * Zynq, std::shared_ptr<Config> Con
/* add acquisition with the analog board */
std::thread analog(&ArduinoManager::ProcessAnalogData, this->Analog, ConfigOut);

#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
/* add acquisition with thermistors if required */
if (CmdLine->therm_on) {
this->Thermistors->Init();
Expand All @@ -1084,9 +1084,8 @@ int DataAcquisition::CollectData(ZynqManager * Zynq, std::shared_ptr<Config> Con

/* wait for other acquisition threads to join */
analog.join();
printf("fattoooo analog join\n");

#if ARDUINO_DEBUG ==0
#if ARDUINO_DEBUG !=1
collect_main_data.join();
ftp_poll.join();

Expand Down
72 changes: 41 additions & 31 deletions CPU/CPUsoftware/src/subsystems/ArduinoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ int ArduinoManager::AnalogDataCollect() {
//printf("Will now run ArduinoManager::SerialReadOut() once...\n");

SerialReadOut(0x00);
#elif ARDUINO_DEBUG ==2

int i, j;

/* Just fill AnalogAcq with zeros */
for (i = 0; i < FIFO_DEPTH; i++) {
for (j = 0; j < CHANNELS; j++) {
this->analog_acq->val[i][j] = 0;
}
}

#else
/* test implementation for now, just prints output to screen */
int fd;
Expand Down Expand Up @@ -300,8 +311,7 @@ int ArduinoManager::GetLightLevel()
}

/* read out multiplexed sipm 64 values and averages of sipm 1 and photodiodes */
for(i = 0; i < AVERAGE_DEPTH; i++)
{
for(i = 0; i < AVERAGE_DEPTH; i++) {
/* read out the data */
AnalogDataCollect();

Expand All @@ -312,36 +322,36 @@ int ArduinoManager::GetLightLevel()
sum_ph[3] += (float)(this->analog_acq->val[0][3]);

/* sum the one channel SiPM values */
for (k = 0; k < N_CHANNELS_SIPM; k++) {
sum_sipm[k] += (float)(this->analog_acq->val[0][4+k]);
}
for (k = 0; k < N_CHANNELS_SIPM; k++) {
sum_sipm[k] += (float)(this->analog_acq->val[0][4+k]);
}

/* read out the multiplexed 64 channel SiPM values */
// {
//std::unique_lock<std::mutex> lock(this->m_light_level);
// this->light_level->sipm_data[i] = this->analog_acq->val[i][5];
// } /* release mutex */
}
}

/* average the photodiode values */
for (k = 0; k < N_CHANNELS_PHOTODIODE; k++)
{
{
std::unique_lock<std::mutex> lock(this->m_light_level);
this->light_level->photodiode_data[k] = sum_ph[k] / AVERAGE_DEPTH;
} /* release mutex */

}
//printf("\n GetLightLevel: photodiode_data: %f", this->light_level->photodiode_data[0]);
/* average the one channel SiPM values */
for (k = 0; k < N_CHANNELS_SIPM; k++)
{
{
std::unique_lock<std::mutex> lock(this->m_light_level);
this->light_level->sipm_data[k] = sum_sipm[k] / AVERAGE_DEPTH;
} /* release mutex */
}
return 0;
for (k = 0; k < N_CHANNELS_PHOTODIODE; k++)
{
{
std::unique_lock<std::mutex> lock(this->m_light_level);
this->light_level->photodiode_data[k] = sum_ph[k] / AVERAGE_DEPTH;
} /* release mutex */
}
//printf("\n GetLightLevel: photodiode_data: %f", this->light_level->photodiode_data[0]);
/* average the one channel SiPM values */
for (k = 0; k < N_CHANNELS_SIPM; k++)
{
{
std::unique_lock<std::mutex> lock(this->m_light_level);
this->light_level->sipm_data[k] = sum_sipm[k] / AVERAGE_DEPTH;
} /* release mutex */
}
return 0;
}

/*
Expand Down Expand Up @@ -371,15 +381,15 @@ ArduinoManager::LightLevelStatus ArduinoManager::CompareLightLevel(std::shared_p
float ph_avg = 0;
int i;

#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG != 1
clog << "info: " << logstream::info << "comparing light level to day and night thresholds" << std::endl;
#else
printf("comparing light level to day and night thresholds \n");
#endif

printf("CompareLightLevel: light level before GetLightLevel %f \n", this->light_level->photodiode_data[0]);
//printf("CompareLightLevel: light level before GetLightLevel %f \n", this->light_level->photodiode_data[0]);
this->GetLightLevel();
printf("CompareLightLevel: light level after GetLightLevel %f \n", this->light_level->photodiode_data[0]);
//printf("CompareLightLevel: light level after GetLightLevel %f \n", this->light_level->photodiode_data[0]);
{
std::unique_lock<std::mutex> lock(this->m_light_level);
auto light_level = this->light_level;
Expand All @@ -402,7 +412,7 @@ ArduinoManager::LightLevelStatus ArduinoManager::CompareLightLevel(std::shared_p
}

/* debug */
#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG != 1
clog << "info: " << logstream::info << "average photodiode reading is: " << ph_avg << std::endl;
#else
//printf("average photodiode reading is: %f, %f", ph_avg,light_level->photodiode_data[0]);
Expand All @@ -413,7 +423,7 @@ ArduinoManager::LightLevelStatus ArduinoManager::CompareLightLevel(std::shared_p
if (ph_avg >= ConfigOut->day_light_threshold) {
//printf("\n CompareLightLevel: photodiode_data: %f , %d", this->light_level->photodiode_data[0], ConfigOut->day_light_threshold);
current_lightlevel_status = ArduinoManager::LIGHT_ABOVE_DAY_THR;
#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG != 1
clog << "info: " << logstream::info << "light level is ABOVE day_light_threshold" << std::endl;
#else
printf("light level is ABOVE day_light_threshold \n");
Expand All @@ -422,7 +432,7 @@ ArduinoManager::LightLevelStatus ArduinoManager::CompareLightLevel(std::shared_p

else if (ph_avg <= ConfigOut->night_light_threshold) {
current_lightlevel_status = ArduinoManager::LIGHT_BELOW_NIGHT_THR;
#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG != 1
clog << "info: " << logstream::info << "light level is BELOW night_light_threshold" << std::endl;
#else
printf("light level is BELOW night_light_threshold \n");
Expand All @@ -431,7 +441,7 @@ ArduinoManager::LightLevelStatus ArduinoManager::CompareLightLevel(std::shared_p

else if (ph_avg > ConfigOut->night_light_threshold && ph_avg < ConfigOut->day_light_threshold) {
current_lightlevel_status = ArduinoManager::LIGHT_UNDEF;
#if ARDUINO_DEBUG == 0
#if ARDUINO_DEBUG != 1
clog << "info: " << logstream::info << "light level is BETWEEN night_light_threshold and day_light_threshold" << std::endl;
#else
printf("light level is BETWEEN night_light_threshold and day_light_threshold \n");
Expand Down
4 changes: 2 additions & 2 deletions CPU/CPUsoftware/src/subsystems/ArduinoManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

// 0 REAL HW
// 1 simulator
#define ARDUINO_DEBUG 1

// 2 use with Arduino connected (ie. automatically in night mode)
#define ARDUINO_DEBUG 2

//#define PRINT_DEBUG_INFO 1
// COMMENT no debug
Expand Down
2 changes: 2 additions & 0 deletions CPU/CPUsoftware/src/subsystems/ZynqManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class ZynqManager {
SELF = 4,
IMMEDIATE = 8,
EXTERNAL = 16,
TA_TRIGGER = 32, /* EUSO-TA TRIGGER, cannot be used in compound modes */

/**
* compound modes
*/
Expand Down
4 changes: 2 additions & 2 deletions CPU/CPUsoftware/src/tools/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include "log.h"

#define CONFIG_FILE_USB "/media/usb/main_cpu.conf"
#define CONFIG_FILE_LOCAL "/home/minieuso_cpu/CPU/CPUsoftware/config/main_cpu.conf"
#define CONFIG_FILE_LOCAL "/home/software/CPU/CPUsoftware/config/main_cpu.conf"
#ifndef __APPLE__
#define CONFIG_DIR "/home/minieuso_cpu/CPU/CPUsoftware/config"
#define CONFIG_DIR "/home/software/CPU/CPUsoftware/config"
#else
#define CONFIG_DIR "config"
#endif /* __APPLE__ */
Expand Down
5 changes: 4 additions & 1 deletion CPU/CPUsoftware/src/tools/InputParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ CmdLineInputs * InputParser::ParseCmdLineInputs() {
else if (mode == "trigger") {
this->CmdLine->zynq_mode = ZynqManager::TRIGGER;
}
else if (mode == "ta_trigger") {
this->CmdLine->zynq_mode = ZynqManager::TA_TRIGGER;
}
else {
std::cout << "Error: for -zynq option the mode could not be identified, use mecontrol -help to check the available modes" << std::endl;
return NULL;
Expand Down Expand Up @@ -512,7 +515,7 @@ int InputParser::PrintHelpMsg() {
std::cout << "ACQUISITION" << std::endl;
std::cout << std::endl;
std::cout << "-short <N>: run a short acquisition of N CPU_PACKETs"<< std::endl;
std::cout << "-zynq <MODE>: use the Zynq acquisition mode (<MODE> = none, periodic, self, immediate, external trigger, default = periodic)" << std::endl;
std::cout << "-zynq <MODE>: use the Zynq acquisition mode (<MODE> = none, periodic, self, immediate, external, trigger, ta_trigger, default = periodic)" << std::endl;
std::cout << "-test_zynq <MODE>: use the Zynq test mode (<MODE> = none, ecasic, pmt, pdm, l1, l2, l3, default = pdm)" << std::endl;
std::cout << "-keep_zynq_pkt: keep the Zynq packets on FTP" << std::endl;
std::cout << "-zynq_reboot: reboot the Zynq for this acquisition" << std::endl;
Expand Down
7 changes: 5 additions & 2 deletions docs/usage/functionality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The Zynq handles the collection of data from the PMTs via the SPACIROC3 ASICs. T

**Main acquisiton modes**

There are five basic acquisition modes, as defined here:
There are five basic acquisition modes, as defined here (for ``TA_TRIGGER`` see EUSO-TA trigger section below):

.. doxygenenum:: ZynqMode

Expand All @@ -131,7 +131,10 @@ Will start an acquisition using both ``periodic`` and ``self`` modes. This means

The multi-level trigger is described in detail in A. Belov et al., *The integration and testing of the Mini-EUSO multi-level trigger system*. Advances in Space Reasearch (2017).


**EUSO-TA trigger mode**

* ``ta_trigger``: This sets the EUSO-TA trigger mode for testing. At the moment, it is not possible to use this in combination with any of the other trigger modes described above.

**Test acquisition modes**

The Zynq also has built in test modes for debugging, where data is provided by the software instead of collected from the ASICs. These modes are defined in ZynqManager::TestMode and are descibed here.
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 7.7
#define VERSION_DATE_STRING "17/04/2019"
#define VERSION 7.8
#define VERSION_DATE_STRING "06/05/2019"

/*
* instrument definitions
Expand Down

0 comments on commit 9b1e1bb

Please sign in to comment.