--- /dev/null
+*snm
+*toc
+*nav
+*run.xml
+*bcf
+*aux
+*out
+*log
+scratch
--- /dev/null
+// this is example for
+
+#include <cstdlib>
+
+#include "hadaq/TdcProcessor.h"
+#include "hadaq/TrbProcessor.h"
+#include "hadaq/HldProcessor.h"
+#include "base/ProcMgr.h"
+#include "mimosis.h"
+
+
+void first()
+{
+ //base::ProcMgr::instance()->SetRawAnalysis(true);
+ base::ProcMgr::instance()->SetTriggeredAnalysis(true);
+
+ // all new instances get this value
+ base::ProcMgr::instance()->SetHistFilling(4);
+
+ // [min..max] range for TDC ids
+ //hadaq::TrbProcessor::SetTDCRange(0x610, 0x613);
+ hadaq::TrbProcessor::SetTDCRange(0x0000, 0x5fff);
+
+ // [min..max] range for HUB ids
+ hadaq::TrbProcessor::SetHUBRange(0x8000, 0x8fff);
+
+ // when first argument true - TRB/TDC will be created on-the-fly
+ // second parameter is function name, called after elements are created
+ hadaq::HldProcessor* hld = new hadaq::HldProcessor(false, "after_create");
+
+
+ //--------------------------------------------------------------------------------------
+
+ // create TRB processor which holds custom data
+ hadaq::TrbProcessor* trb = new hadaq::TrbProcessor(0xa000, hld);
+ // create custom processor
+ hadaq::MimosisProcessor *mimosis = new hadaq::MimosisProcessor(trb, 0xa000);
+
+
+
+}
+
+// extern "C" required by DABC to find function from compiled code
+
+extern "C" void after_create(hadaq::HldProcessor* hld)
+{
+ printf("Called after all sub-components are created\n");
+
+ if (hld==0) return;
+
+ for (unsigned k=0;k<hld->NumberOfTRB();k++) {
+ hadaq::TrbProcessor* trb = hld->GetTRB(k);
+ if (trb==0) continue;
+
+
+ printf("Configure %s!\n", trb->GetName());
+ trb->SetPrintErrors(10);
+ }
+
+
+}
+
+
--- /dev/null
+#ifndef MimosisProcessor_h
+#define MimosisProcessor_h
+
+#include "hadaq/SubProcessor.h"
+
+
+
+namespace hadaq {
+
+class TrbProcessor;
+
+ /** This is specialized sub-processor for custom data.
+ * It should be used together with TrbProcessor,
+ * which the only can provide data
+ **/
+
+class MimosisProcessor : public SubProcessor {
+
+ friend class TrbProcessor;
+
+protected:
+
+ base::H1handle FrameLength;
+ base::H1handle NumHeaders;
+ base::H1handle NumTrailers;
+ base::H1handle NumHTDiff;
+ base::H1handle RegionHeaders;
+ base::H1handle Columns;
+ base::H1handle ErrorFlags;
+ base::H2handle Matrix;
+
+ uint32_t length = 0;
+ uint32_t region = 0;
+
+ virtual bool DecodePixel(uint16_t word, uint32_t* column, uint32_t* row) {
+ uint32_t pixelcode = (word >> 6) & 0x3ff;
+ uint32_t side = 0;
+ uint32_t topdown = 0;
+ if((pixelcode&3) == 0x1 || (pixelcode&3) == 0x2)
+ side = 1;
+ if((pixelcode&3) == 0x3 || (pixelcode&3) == 0x2)
+ topdown = 1;
+
+ *row = (pixelcode>>2)*2 + topdown;
+ *column = (((word>>3)&0x7) + region*8)*2 + side;
+ return true;
+ }
+
+public:
+
+ MimosisProcessor(TrbProcessor* trb, unsigned subid);
+ virtual ~MimosisProcessor() {}
+
+
+ /** Scan all messages, find reference signals
+ * if returned false, buffer has error and must be discarded */
+ virtual bool FirstBufferScan(const base::Buffer&);
+
+ /** Scan buffer for selecting messages inside trigger window */
+ virtual bool SecondBufferScan(const base::Buffer&) { return true; }
+};
+
+}
+
+
+
+hadaq::MimosisProcessor::MimosisProcessor(TrbProcessor* trb, unsigned subid) :
+ hadaq::SubProcessor(trb, "%04X", subid)
+{
+ FrameLength = MakeH1("FrameSize", "32bit words", 3000, 0, 3000, "ch");
+ NumHeaders = MakeH1("NumHeaders", "", 2000, 0, 2000, "#");
+ NumTrailers = MakeH1("NumTrailers", "Consecutive Frames", 500, 0, 500, "#");
+ NumHTDiff = MakeH1("Difference Trailer Headers", "", 20, -10, 10, "#");
+ RegionHeaders = MakeH1("RegionHeaders", "", 64, 0, 63, "#");
+ Columns = MakeH1("Columns", "Hits per Column", 1024, 0, 1024, "#");
+ ErrorFlags = MakeH1("ErrorFlags", "", 9, 0, 9, "Bit");
+ Matrix = MakeH2("Matrix", "", 1024,0,1024,508,0,508);
+ }
+
+bool hadaq::MimosisProcessor::FirstBufferScan(const base::Buffer &buf)
+{
+ unsigned len = buf.datalen()/4;
+ uint32_t* arr = (uint32_t*) buf.ptr();
+ uint32_t column, row;
+ uint32_t headers = 0, trailers = 0;
+ unsigned n=0;
+ unsigned headersnow = 0;
+// length = 0;
+
+// do {
+// }while(!((arr[++n] & 0xFF000000) == 0xFE000000));
+
+ for (;n<len;n++) {
+ uint32_t data = arr[n];
+ length++;
+ if((data & 0xFF000000) == 0xFE000000) {
+ headers++;
+ headersnow++;
+ length = 0;
+ }
+ else if((data & 0xFF000000) == 0xFF000000) {
+ trailers++;
+ if (headersnow && headersnow != 4) {
+ printf("%i\t%i\n",headersnow,n);
+ if(n>6) {
+ printf("%08x %08x %08x %08x %08x %08x %08x %08x\n",arr[n-7],arr[n-6],arr[n-5],arr[n-4],arr[n-3],arr[n-2],arr[n-1],arr[n]);
+ }
+ }
+ headersnow = 0;
+ FillH1(FrameLength,length);
+ if(data & 0x00010000) FillH1(ErrorFlags,0);
+ if(data & 0x00020000) FillH1(ErrorFlags,1);
+ if(data & 0x00040000) FillH1(ErrorFlags,2);
+ if(data & 0x00080000) FillH1(ErrorFlags,3);
+ if(data & 0x00100000) FillH1(ErrorFlags,4);
+ if(data & 0x00200000) FillH1(ErrorFlags,5);
+ if(data & 0x00400000) FillH1(ErrorFlags,6);
+ if(data & 0x00800000) FillH1(ErrorFlags,7);
+ if(!(data & 0x00FF0000)) FillH1(ErrorFlags,8);
+ }
+ else {
+ if (headersnow && headersnow != 4) {
+ printf("%i\t%i\n",headersnow,n);
+ if(n>6) {
+ printf("%08x %08x %08x %08x %08x %08x %08x %08x\n",arr[n-7],arr[n-6],arr[n-5],arr[n-4],arr[n-3],arr[n-2],arr[n-1],arr[n]);
+ }
+ }
+ headersnow = 0;
+ if((data & 0xFF000000) == 0xFD000000) {
+ region = (data>>16) & 0xff;
+ FillH1(RegionHeaders,region);
+ }
+ else {
+ DecodePixel(data>>16,&column,&row);
+ FillH1(Columns,column);
+ FillH2(Matrix,column,row);
+ }
+ if ((data & 0x0000FF00) != 0x0000FC00) {
+ DecodePixel(data&0xffff,&column,&row);
+ FillH1(Columns,column);
+ FillH2(Matrix,column,row);
+ }
+ }
+
+ }
+
+
+ FillH1(NumHeaders, headers);
+ FillH1(NumTrailers, trailers);
+ FillH1(NumHTDiff, ((int32_t)headers)/4-trailers);
+
+ return true;
+ }
+
+
+#endif
--- /dev/null
+#include "base/EventProc.h"
+#include "hadaq/TdcSubEvent.h"
+#include "hadaq/HldProcessor.h"
+#include "TString.h"
+
+//#include "base/Event.h"
+//#include "base/TimeStamp.h"
+// #include "hadaq/HldProcessor.h"
+
+#define MAXCH 64
+
+class SecondProc : public base::EventProc {
+protected:
+ std::string fTdcId; //!< tdc id where channels will be selected
+ base::H2handle hDiff;
+ base::H2handle hPrevDiff;
+ base::H2handle hRiseRef;
+
+ base::H2handle hFineCh;
+ base::H2handle hFineRiseCh;
+ base::H2handle hFineFallCh;
+ base::H2handle hDiffToScint[17];
+ base::H1handle hScintCor;
+ base::H2handle hSciTot[4];
+
+
+public:
+
+ SecondProc(const char* procname, const char* _tdcid);
+ virtual void CreateBranch(TTree* t);
+ virtual bool Process(base::Event* ev);
+};
+
+
+
+SecondProc::SecondProc(const char* procname, const char* _tdcid) :
+ base::EventProc(procname),
+ fTdcId(_tdcid)
+{
+ hDiff = MakeH2("Tdiff","Tdiff", MAXCH, 0, MAXCH, 50000, -100, 300, "ns");
+ hPrevDiff = MakeH2("TPrevdiff","TPrevdiff", MAXCH, 0, MAXCH, 50000, -300, 300, "ns");
+ hRiseRef = MakeH2("TRiseRef","Tdiffch", MAXCH, 0, MAXCH, 40000, -100, 100, "ns");
+ hFineCh = MakeH2("Finech","Fine distribution channels", MAXCH, 0, MAXCH, 600, 0, 600, "");
+ hFineRiseCh = MakeH2("FineRisech","Fine rising", MAXCH, 0, MAXCH, 600, 0, 600, "");
+ hFineFallCh = MakeH2("FineFallch","Fine falling", MAXCH, 0, MAXCH, 600, 0, 600, "");
+//
+// hScintCor = MakeH1("ScintCor","Scint Cor",10000,-100,100,"ns");
+// for(unsigned i = 9; i<=16; i++) {
+// hDiffToScint[i] = MakeH2(TString::Format("DiffToScint_%d", i),"to sum26/27", 1000, -50, 0, 150, 0, 50, "ns");
+// }
+// for(unsigned i = 0; i<=3; i++) {
+// hSciTot[i] = MakeH2(TString::Format("hSciTot_%d", i),"", 1000, -5, 5, 800, 0, 400, "ns");
+// }
+}
+
+
+
+void SecondProc::CreateBranch(TTree* t)
+{
+ // only called when tree is created in first.C
+ // one can ignore
+ // t->Branch(GetName(), fHits, "hits[8]/D");
+}
+
+bool SecondProc::Process(base::Event* ev)
+{
+ hadaq::TdcSubEvent* sub =
+ dynamic_cast<hadaq::TdcSubEvent*> (ev->GetSubEvent(fTdcId));
+ if (!sub) {
+ printf("Fail to find %s\n", fTdcId.c_str());
+ return false;
+ }
+
+ hadaq::HldSubEvent *hld = dynamic_cast<hadaq::HldSubEvent*> (ev->GetSubEvent("HLD"));
+// if (hld)
+// printf("HLD: type %u seq %u run %u\n", hld->fMsg.trig_type,
+// hld->fMsg.seq_nr, hld->fMsg.run_nr);
+
+ unsigned trigtype = hld->fMsg.trig_type;
+
+ double last_stamp[2000][64];
+ unsigned id = std::stoi(fTdcId.substr(4).c_str());
+// printf("%u",id);
+
+
+// double ch0tm = 0,ch1tm=0;
+// double ch17 = 0, ch24 = 0, ch26 = 0,ch25 = 0;
+// double tot17 = 0, tot26=0;
+// double lead = 0;
+ for (unsigned ihit=0;ihit<sub->Size();ihit++) {
+ hadaq::TdcMessageExt &ext = sub->msg(ihit);
+
+ unsigned ch = ext.msg().getHitChannel();
+ unsigned edge = ext.msg().getHitEdge();
+ double stamp = ext.GetGlobalTime(); // here in seconds
+
+
+ if(edge == 1) {
+ last_stamp[id][ch] = stamp;
+ }
+ }
+
+// if(ch==26 && edge == 1) {ch26 = stamp;}
+// if(ch==26 && edge == 0) {tot26 = stamp-ch26;}
+// if(ch==25 && edge == 1) {ch25 = stamp;}
+//
+// if(ch==17 && edge == 1) {ch17 = stamp;}
+// if(ch==17 && edge == 0) {tot17 = stamp-ch17;}
+// if(ch==24 && edge == 1) {ch24 = stamp;}
+//
+//
+// if(ch==26 && edge == 0 && ch25 != 0 && ch24!=0 && ch17 !=0) {
+// FillH2(hSciTot[0], ((ch26-ch25))*1E9,(tot26)*1E9);
+// FillH2(hSciTot[1], ((ch26+ch25)/2-(ch24+ch17)/2)*1E9,(tot26)*1E9);
+// FillH2(hSciTot[2], ((ch26+ch25)/2-(ch24+ch17)/2)*1E9,(tot17)*1E9);
+// }
+//
+// }
+// ch0tm = (ch26+ch25)/2;
+// ch1tm = (ch17+ch24)/2;
+// if (ch26 != 0 && ch25 != 0 && ch24 != 0 && ch17 != 0) {
+// FillH1(hScintCor,(ch0tm-ch1tm)*1E9);
+// }
+
+// if(ch1tm != 0) {
+// for (unsigned ihit=0;ihit<sub->Size();ihit++) {
+// hadaq::TdcMessageExt &ext = sub->msg(ihit);
+// unsigned ch = ext.msg().getHitChannel();
+//
+// if(ch >= 9 && ch <= 16) {
+// unsigned edge = ext.msg().getHitEdge();
+// double stamp = ext.GetGlobalTime(); // here in seconds
+// if(edge == 1) {
+// lead = stamp;
+// }
+// if(edge == 0) {
+// FillH2(hDiffToScint[ch], (lead-ch1tm)*1E9,(stamp-lead)*1E9);
+// }
+// }
+// }
+// }
+
+
+
+
+
+ for (unsigned ihit=0;ihit<sub->Size();ihit++) {
+
+ hadaq::TdcMessageExt &ext = sub->msg(ihit);
+
+ unsigned ch = ext.msg().getHitChannel();
+ unsigned edge = ext.msg().getHitEdge();
+ unsigned fine = ext.msg().getHitTmFine();
+ unsigned coarse = ext.msg().getHitTmCoarse();
+ double stamp = ext.GetGlobalTime(); // here in seconds
+
+// if(ch > 0 && edge == 1 && id==507) {
+// FillH2(hDiff, ch, (last_stamp[300][ch]-stamp)*1E9);
+// }
+ if(ch > 1 && edge == 1) {
+ FillH2(hPrevDiff, ch, (last_stamp[id][ch-1]-stamp)*1E9);
+ }
+
+// if (ch==0) { ch0tm = stamp; } // ch0 has absolute time, all other channels relative to ch0
+
+ if( (stamp < 50e-9 && stamp > -10e-9) || ch == 0 || trigtype != 0xd) {
+
+ if(edge == 1) {
+ FillH2(hFineRiseCh, ch, fine);
+// printf("%i\n",id*64+ch);
+ FillH2(hDiff, ch, (last_stamp[0][0]-stamp)*1E9);
+ last_stamp[id][ch] = stamp;
+ last_stamp[0][0] = stamp;
+
+ FillH2(hRiseRef, ch, stamp*1E9);
+ }
+
+
+ if(edge == 0)
+ FillH2(hFineFallCh, ch, fine);
+
+ FillH2(hFineCh, ch, fine);
+
+ }
+ }
+
+
+
+
+
+// // failure, but just keep it here
+// // if (ch>=MAXCH) continue;
+//
+// // printf("ch %u edge %u stamp %f\n", ch, edge, stamp*1e9);
+
+// if (edge==0) {
+// last_rising[ch] = stamp;
+//
+// }
+// } else if (!last_rising[ch]) {
+// // printf(" ToT %f\n", stamp - last_rising[ch]);
+// FillH1(hToT, stamp - last_rising[ch]);
+// FillH2(hToTCh, ch, stamp - last_rising[ch]);
+// last_rising[ch] = 0;
+// }
+
+ return true;
+}
+
+// void second()
+// {
+//
+// // for (auto &entry : ev->GetEventsMap())
+// // printf("Name %s Instance %p\n", entry.first.c_str(), entry.second);
+//
+// // new SecondProc("x0050", "TDC_0050");
+// // new SecondProc("x0507", "TDC_0507");
+// // new SecondProc("x0303", "TDC_0303");
+// new SecondProc("x0201", "TDC_0201");
+// new SecondProc("x0203", "TDC_0203");
+// }
+
+
+
+class SecondCreator : public base::EventProc {
+public:
+
+ bool fCreated{false};
+
+ SecondCreator(const char *name) : base::EventProc(name) {}
+
+ virtual bool Process(base::Event* ev)
+ {
+ if (fCreated)
+ return true;
+
+ if (ev->NumSubEvents() == 0)
+ return false;
+
+ for (auto &entry : ev->GetEventsMap()) {
+
+ if (entry.first.compare(0,3,"TDC") == 0) {
+ std::string procname = std::string("x") + entry.first.substr(4);
+ new SecondProc(procname.c_str(), entry.first.c_str());
+ printf("CREATE SECOND for %s\n", entry.first.c_str());
+ fCreated = true;
+ }
+ }
+
+ return true;
+ }
+
+};
+
+
+void second()
+{
+ new SecondCreator("Creator");
+ //new SecondProc("x0050", "TDC_0050");
+ //new SecondProc("x0507", "TDC_0507");
+ //new SecondProc("x0303", "TDC_0303");
+}
+
+
+
+
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+This is example file how HADAQ event building should be configured in DABC.
+Event building process implemented in Combiner module of hadaq::CombinerModule class.
+Module can have several inputs, each with separate port number for receiving data
+from TRB boards. For every input one could configure only UDP port number - host name is ignored.
+First output of combiner module reserved for the connection to the MBS transmitter module.
+Second output can be use to store data in hld files.
+To enable HLD file storage one should specify NumOutputs for Combiner module
+and provide hld file name for Output1 port
+ <control value="false"/>
+
+ <NumOutputs value="2"/>
+ <OutputPort name="Output1" url="hld://dabc.hld?maxsize=2000"/>
+
+File name fill be extended according to HADAQ naming convetion.
+
+Optionally one can enable MBS transmitter module, which converts HLD to LMD format.
+To enable transmitter, one should specify auto="true" in configuration which says DABC
+to automatically create module when starting application.
+First output of the module reserved for stream server, second output can be used to
+store data in lmd files.
+
+By default, HTTP server is enabled. Do disable it, remove <HttpServer> section or
+put <HttpServer name="http" auto="false">. One could change http port number.
+When dabc runs, in any browser address like
+http://your_dabc_host_name:8090 can be opened. At the moment http server provides:
+ - ratemeters from EventBuilder and Transmitter
+ - log fields
+ - commands to start/stop hld and lmd files from browser
+
+It is also possible to attach go4 analysis to that server, that also histograms
+from online analysis will appear. For that one should specify
+"-dabc your_dabc_host_name" argument when starting analysis. Like:
+ [shell] go4analysis -stream dabc_node -dabc dabc_node
+When launching analysis from the gui, extra arguments "-dabc your_dabc_host_name"
+should be specified.
+
+There is well-known problem with using VNC viewer and mbs stream server.
+Both by default are using port 6002. One could change port number for stream server.
+Just set other number in configuration of output port of transmitter module, for instance
+ <OutputPort name="Output0" url="mbs://Stream:6789"/>
+In this case one should specify that port number when starting go4 analysis like:
+ [shell] go4analysis -stream dabc_node:6789 -dabc dabc_node:4444
+When starting analysis from the go4 gui, one should specify stream server with port number too.
+
+-->
+
+<dabc version="2">
+ <Context host="localhost" name="EventBuilder">
+ <Run>
+ <lib value="libDabcMbs.so"/>
+ <lib value="libDabcHadaq.so"/>
+ <lib value="libDabcHttp.so"/>
+ <lib value="libDabcStream.so"/>
+ <logfile value="hadaqevtbuild.log"/>
+ <loglevel value="-1"/>
+ <loglimit value="1000"/>
+ <control value="false"/>
+ <threads_layout value="balanced"/>
+ </Run>
+
+ <HttpServer name="http" port="8091"/>
+ <!-- If uncommented, all internal manager structures will be published in the web server -->
+ <!-- Publisher name="publ" manager="true"/ -->
+
+ <!-- If uncommented, profiling will be enabled for all threads -->
+ <!-- Thread name="*" publ="true" prof="true"/ -->
+
+ <MemoryPool name="Pool">
+ <BufferSize value="2000000"/>
+ <NumBuffers value="1000"/>
+ </MemoryPool>
+
+ <!-- these are default parameters for TDC calibration modules -->
+ <Module name="Input*TdcCal">
+ <InputPort name="Input*" queue="30"/>
+
+ <FineMin value="31"/>
+ <FineMax value="515"/>
+ <NumChannels value="33"/>
+ <EdgeMask value="2"/> <!-- 1: only leading edge 2:leading/trailing individual 3:statistics from leading used 4:statistics merged -->
+ <HistFilling value="4"/>
+ <CalibrFile value="/workdir/tdc_calib"/> <!-- local/-->
+ <!--DisableCalibrationFor value="0"/-->
+ <Auto value="100000"/>
+
+ <!-- TRB value="0x8010"/-->
+ <!-- HUB value="0x9000"/-->
+ <!-- TDC value="[0x8a00,0x8a01,0x8a02,0x8a03]"/-->
+ <Dummy value="true"/>
+ </Module>
+
+
+ <Module name="Combiner" class="hadaq::CombinerModule">
+ <!-- these parameters will force to create inputs/outputs of module -->
+ <NumInputs value="1"/>
+ <NumOutputs value="1"/>
+
+
+<!-- <InputPort name="Input0" url="hadaq://host:51001" urlopt1=""/><!-- -->
+ <InputPort name="Input0" url="hadaq://host:50302" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input1" url="hadaq://host:50245" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input1" url="hadaq://host:50018" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input1" url="hadaq://host:50031" urlopt1=""/><!-- -->
+ <InputPort name="Input1" url="hadaq://host:50030" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input1" url="hadaq://host:51000" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input0" url="hadaq://host:51001" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input1" url="hadaq://host:51002" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input0" url="hadaq://host:50061" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input1" url="hadaq://host:50008" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input2" url="hadaq://host:50084" urlopt1=""/><!-- -->
+<!-- <InputPort name="Input3" url="hadaq://host:50158" urlopt1=""/><!-- -->
+
+
+ <!-- <InputPort name="Input4" url="hadaq://host:10104" urlopt1="trb=0x8030&tdc=[0x3030,0x3031,0x3032,0x3033]&dummy"/> -->
+ <!-- <InputPort name="Input5" url="hadaq://host:10105" urlopt1="trb=0x8040&tdc=[0x3040,0x3041,0x3042,0x3043]&dummy"/> -->
+
+ <!-- <InputPort name="Input0" url="hadaq://host:50021" urlopt1="trb=0x8000&hub=0x8100&tdc=[0xC000,0xC001,0xC003]&dummy"/> -->
+ <!-- <InputPort name="Input1" url="hadaq://host:50094" urlopt1="trb=0x8003&tdc=[0xC00C,0xC00D,0xC00E,0xC00F]&dummy"/> -->
+ <!-- <InputPort name="Input2" url="hadaq://host:50096" urlopt1="trb=0x8002&tdc=[0xC008,0xC009,0xC00A,0xC00B]&dummy"/> -->
+ <!-- <InputPort name="Input3" url="hadaq://host:10104" urlopt1="trb=0x8030&tdc=[0x3030,0x3031,0x3032,0x3033]&dummy"/> -->
+ <!-- <InputPort name="Input4" url="hadaq://host:10105" urlopt1="trb=0x8040&tdc=[0x3040,0x3041,0x3042,0x3043]&dummy"/> -->
+
+ <!-- <InputPort name="Input*" queue="30"
+ urlopt="udpbuf=20000&mtu=64512&flush=3.0&observer=false&debug&resort"/>
+ -->
+
+ <InputPort name="Input*" queue="30" urlopt="udpbuf=400000&mtu=64512&flush=1&observer=false&debug"/>
+
+ <ExtraDebug value="false"/>
+
+ <!-- this is stream server for online monitoring, normally always on -->
+ <OutputPort name="Output0" url="mbs://Stream:36789?iter=hadaq_iter&subid=0x1f"/>
+
+ <!-- this is example of HLD file storage - local and RFIO -->
+ <OutputPort name="Output1" url="hld:///local/mimosis/scratch/Mimosis_data.hld?maxsize=2000"/>
+ <!--OutputPort name="Output1" url="hld:///linev/path/dabc.hld?maxsize=1900&rfio"/-->
+
+ <DoShmControl value="false"/>
+ <FlushTimeout value="1.0"/>
+ <BuildDropTimeout value="1000"/>
+
+ <!-- take event sequence number from vulom/roc sync message at cts -->
+ <UseSyncSequenceNumber value="false"/>
+ <SyncSubeventId value="0x8000"/>
+ <SyncTriggerMask value="0x01"/>
+ <PrintSync value="false"/>
+ <FlushBySync value="false"/>
+
+ <!--TriggerNumRange: defines when trigger sequence number wraps. only 16 bit for HADES EBs, 24 bit for trb3! -->
+ <TriggerNumRange value="0x10000"/>
+
+ <!--AccountLostEventDiff: if true, missing trigger sequence number are added as lost events to stats. Disabled for multiple event builder mode! -->
+ <AccountLostEventDiff value="true"/>
+
+ <!-- rate meters configuration -->
+ <HadaqData width="4" prec="2" low="0" up="10" debug="1"/>
+ <HadaqEvents width="5" prec="1" low="0" up="1000" debug="1"/>
+ <HadaqDroppedData width="5" prec="3" low="0" up="1" debug="1"/>
+ <HadaqLostEvents width="4" prec="2" low="0" up="100" debug="1"/>
+ </Module>
+
+ <!-- Uncomment to see terminal output like old event builder -->
+ <Module name="Term" class="hadaq::TerminalModule" period="0.3" clear="false"/>
+
+ </Context>
+
+</dabc>
--- /dev/null
+#read files like my @config = do "CONF_allregisters.pl";
+
+ #General Control
+ [0x0020, 0x40 ], #RUNMODE -> table 8
+ [0x0021, 0x6E ], #TRIMDAC -> table 9
+ [0x0022, 0x00 ], #INJCURR -> table 10
+ [0x0023, 0x00 ], #INJVOLT1 -> table 11
+ [0x0024, 0x00 ], #INJVOLT2 -> table 12
+ [0x0025, 0x00 ], #MONCURR -> table 13
+ [0x0026, 0x00 ], #MONVOLT -> table 14
+ [0x0027, 0x01 ], #CLKGEN1 -> table 15
+ [0x0028, 0x01 ], #CLKGEN2 -> table 16
+ [0x0029, 0x16 ], #PLL -> table 17
+ [0x002a, 0x00 ], #PLLLOCK -> table 18
+ [0x002b, 0x00 ], #MONTEMP -> table 19
+ [0x002c, 0x15 ], #SLVSTX -> table 20
+ [0x002d, 0x00 ], #SLVSRX -> table 21
+ [0x002e, 0x17 ], #OUTPUT -> table 22
+ [0x002f, 0x00 ], #MONPWR -> table 23
+
+ #DACs
+ [0x0040, 0x40 ], #IBIAS 0 - 80 nA , 312 pA Pixel current
+ [0x0041, 0x34 ], #ITHR 0 - 2.5 nA , 9.8 pA Pixel current
+ [0x0042, 0x1c ], #IDB 0 - 40 nA , 157 pA Pixel current
+ [0x0043, 0xab ], #VRESET 0.37 - 1.79 V , 6 mV Pixel input amplifier reset voltage
+ [0x0044, 0x46 ], #VPL 0.37 - 1.79 V , 6 mV Pixel voltage for charge injection (low value)
+ [0x0045, 0x55 ], #VPH 0.37 - 1.79 V , 6 mV Pixel voltage for charge injection (high
+ [0x0046, 0x00 ], #VPH_FINE 0 - 256 mV , 1 mV value) VPH+VPH_FINE
+ [0x0047, 0x43 ], #VCASP 0 - 1.54 V , 6 mV Pixel voltage
+ [0x0048, 0x78 ], #VCASNA 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix A
+ [0x0049, 0x78 ], #VCASNB 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix B
+ [0x004a, 0x78 ], #VCASNC 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix C
+ [0x004b, 0x6d ], #VCASND 0 - 1.54 V , 6 mV Pixel threshold voltage for submatrix D
+ [0x004c, 0x3c ], #VCASN2 0 - 1.54 V , 6 mV Pixel voltage
+ [0x004d, 0x37 ], #VCLIP 0 - 1.54 V , 6 mV Pixel clipping amplifier voltage
+ [0x004e, 0x7d ], #IBUFBIAS 0 - 10 μA , 312 pA Internal buffer bias (not in pixel)
+
+ #Sequencer - 0x0100 registers are upper byte of the word
+ [0x0060, ], # PIXLOAD_A 0x00
+ [0x0160, ], # 0x00
+ [0x0070, ], # PIXLOAD_B 0x01
+ [0x0170, ], # 0x00
+ [0x0061, ], # PIXREAD_A 0x00
+ [0x0161, ], # 0x00
+ [0x0071, ], # PIXREAD_B 0x97
+ [0x0171, ], # 0x00
+ [0x0062, ], # PIXRSTB_A 0x98
+ [0x0162, ], # 0x00
+ [0x0072, ], # PIXRSTB_B 0x99
+ [0x0172, ], # 0x00
+ [0x0063, ], # DPSTART_A 0x00
+ [0x0163, ], # 0x00
+ [0x0073, ], # DPSTART_B 0x01
+ [0x0173, ], # 0x00
+ [0x0064, ], # DPTOKEN_A 0x01
+ [0x0164, ], # 0x00
+ [0x0074, ], # DPTOKEN_B 0x02
+ [0x0174, ], # 0x00
+ [0x0065, ], # DPEND_A 0x98
+ [0x0165, ], # 0x00
+ [0x0075, ], # DPEND_B 0x99
+ [0x0175, ], # 0x00
+ [0x0066, ], # PIXPULSEA_A 0x00
+ [0x0166, ], # 0x00
+ [0x0076, ], # PIXPULSEA_B 0x00
+ [0x0176, ], # 0x00
+ [0x0067, ], # PIXPULSED_A 0x00
+ [0x0167, ], # 0x00
+ [0x0077, ], # PIXPULSED_B 0x00
+ [0x0177, ], # 0x00
+ [0x0068, ], # MKSEQ1_A 0x00
+ [0x0168, ], # 0x00
+ [0x0078, ], # MKSEQ1_B 0x02
+ [0x0178, ], # 0x00
+ [0x0069, ], # MKSEQ2_A 0x00
+ [0x0169, ], # 0x00
+ [0x0079, ], # MKSEQ2_B 0x02
+ [0x0179, ], # 0x00
+ [0x007A, ], # POLARITY 0x05
+ [0x017A, ], # 0x00
+ [0x007B, ], # FRAMELENGTH 100
+ [0x017B, ], # 0x00
+ [0x007C, ], # MAXFRAME 0x00
+ [0x017C, ], # 0x00
+ [0x007D, ], # MODPULSE 0x00
+ [0x007E, ], # MODPIXRSTB 0x00
+ [0x007F, ], # MODMKSEQ1 0x00
+
+ #Monitoring (read only)
+ [0x00E0, ], # MON_POR_LOCK Power On Rest and PLL lock
+ [0x00E1, ], # MON_PAD PADs
+ [0x00E2, ], # MON_FR_CPT_0 Frame counter bits 7-0
+ [0x00E3, ], # MON_FR_CPT_1 Frame counter bits 15-8
+ [0x00E4, ], # MON_FR_CPT_2 Frame counter bits 23-16
+ [0x00E5, ], # MON_FR_CPT_3 Frame counter bits 31-24
+ [0x00E6, ], # EV_TMR_SEQ Triple Modular Redundancy Error in sequencer
+ [0x00E7, ], # EV_LOCK PLL lock
+ [0x00E8, ], # EV_LOCKFILTER PLL lock after filtering
+ [0x00E9, ], # EV_POR1 Power On Reset 1
+ [0x00EA, ], # EV_POR2 Power On Reset 2
+ [0x00EB, ], # EV_POR3 Power On Reset 3
+ [0x00EC, ], # EV_RSTB RSTB pad
+ [0x00ED, ], # EV_START START all types (auto, pad, and soft)
+ [0x00EE, ], # EV_DPSTART Digital Periphery Start
+
+ #Analog pixel selection
+ [0x8020, ], # SEL_ANAPIX0 Analogue Pixel Selection LSB
+ [0x8021, ], # SEL_ANAPIX1 Analogue Pixel Selection MSB
+
+ #Readout test configuration
+ [0x8040, 0xaa ], # PATTERN0
+ [0x8041, 0xfc ], # PATTERN1
+ [0x8042, 0xaa ], # PATTERN2
+ [0x8043, 0xfc ], # PATTERN3
+ [0x8044, 0xaa ], # PATTERN4
+ [0x8045, 0xfc ], # PATTERN5
+ [0x8046, 0xaa ], # PATTERN6
+ [0x8047, 0xfc ], # PATTERN7
+ [0x8048, 0xaa ], # PATTERN8
+ [0x8049, 0xfc ], # PATTERN9
+ [0x804A, 0xaa ], # PATTERN10
+ [0x804B, 0xfc ], # PATTERN11
+ [0x804C, 0xaa ], # PATTERN12
+ [0x804D, 0xfc ], # PATTERN13
+ [0x804E, 0xaa ], # PATTERN14
+ [0x804F, 0xfc ], # PATTERN15
+ [0x8050, ], # BANDWIDTH0
+ [0x8051, ], # BANDWIDTH1
+ [0x8052, 0x00 ], # FILLLEVEL0 #custom level at 1536
+ [0x8053, 0x06 ], # FILLLEVEL1
+
+ #Pixel control registers TBD
+
+ #Multi frame emulation memories TBD
+
--- /dev/null
+package Mimosis;
+
+use warnings;
+no warnings "portable";
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+#use FileHandle;
+#use Data::Dumper;
+
+
+sub adc_i2c_command {
+
+ my ($fpga, $addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte) = @_;
+
+ $reg_data = ($data << 16) + ($cmd << 8) + 0x80 + $addr;
+ $reg_flag = ($readwrite << 8) + ($skipcmd << 4) + $wordbyte;
+
+ if($readwrite == 0) {
+ trb_register_write_mem($fpga,0xd681,0,[$reg_flag,$reg_data],2);
+ }
+ elsif($readwrite == 1) {
+ trb_register_write_mem($fpga,0xd681,0,[$reg_flag,$reg_data],2);
+ usleep(1000);
+ my $reg_return = trb_register_read($fpga,0xd684);
+ return $reg_return->{$fpga} & 0xffff;
+ }
+}
+
+
+sub adc_register_write {
+ my ($fpga, $mimosis_reg, $mimosis_data) = @_;
+ my ($addr, $cmd, $data);
+
+ $addr = 0x12;
+ $cmd = ($mimosis_reg >> 8);
+ $data = (($mimosis_reg & 0xff) << 8) + $mimosis_data;
+
+# printf("%x %x\n", $cmd, $data);
+ adc_i2c_command($fpga, $addr, $cmd, $data, 0, 0, 1);
+}
+
+
+sub adc_register_read {
+ my ($fpga, $mimosis_reg) = @_;
+ my ($addr, $cmd, $data);
+
+ $addr = 0x12;
+ $cmd = ($mimosis_reg >> 8);
+ $data = ($mimosis_reg & 0xff);
+
+# printf("%x %x\n", $cmd, $data);
+ $val = adc_i2c_command($fpga, $addr, $cmd, $data, 1, 0, 1);
+ return $val;
+}
+
+sub mimosis_i2c_command {
+
+ my ($fpga, $addr, $cmd, $data, $readwrite, $skipcmd, $wordbyte) = @_;
+
+ $reg_data = ($data << 16) + ($cmd << 8) + ($addr << 1);
+ $reg_flag = ($readwrite << 8) + ($skipcmd << 4) + $wordbyte;
+
+ if($readwrite == 0) {
+ trb_register_write_mem($fpga,0xde01,0,[$reg_flag,$reg_data,0x1],3);
+ }
+ elsif($readwrite == 1) {
+ trb_register_write_mem($fpga,0xde01,0,[$reg_flag,$reg_data,0x1],3);
+ usleep(1000);
+ my $reg_return = trb_register_read($fpga,0xde04);
+ return $reg_return->{$fpga} & 0xffff;
+ }
+}
+
+
+sub mimosis_register_write {
+ my ($fpga, $mimosis_reg, $mimosis_data) = @_;
+ my ($addr, $cmd, $data);
+
+ $addr = 0x12;
+ $cmd = ($mimosis_reg >> 8);
+ $data = (($mimosis_reg & 0xff) << 8) + $mimosis_data;
+
+# printf("%x %x\n", $cmd, $data);
+ mimosis_i2c_command($fpga, $addr, $cmd, $data, 0, 0, 1);
+}
+
+
+sub mimosis_register_read {
+ my ($fpga, $mimosis_reg) = @_;
+ my ($addr, $cmd, $data);
+
+ $addr = 0x12;
+ $cmd = ($mimosis_reg >> 8);
+ $data = ($mimosis_reg & 0xff);
+ mimosis_i2c_command($fpga, $addr, $cmd, $data, 0, 0, 0);
+ usleep(1000);
+# printf("%x %x\n", $cmd, $data);
+ $addr = 0x15;
+ $val = mimosis_i2c_command($fpga, $addr, 0, 0, 1, 1, 0);
+ return $val;
+}
+
+1;
+
+
+
+
+__END__
--- /dev/null
+#!/usr/bin/perl
+
+use warnings;
+use lib ".";
+use Mimosis;
+
+my $fpga = 0xa000;
+my $addr = 0x12;
+
+my @list = (
+ [0x00, 0x2040],
+ [0x00, 0x216e],
+ [0x00, 0x2200],
+ [0x00, 0x2300],
+ [0x00, 0x2400],
+ [0x00, 0x2500],
+ [0x00, 0x2600],
+ [0x00, 0x2701],
+ [0x00, 0x2801],
+ [0x00, 0x2916],
+ [0x00, 0x2a00],
+ [0x00, 0x2b00],
+ [0x00, 0x2c15],
+ [0x00, 0x2d00],
+ [0x00, 0x2e17],
+ [0x00, 0x2f00],
+
+ [0x00, 0x4040],
+ [0x00, 0x4134],
+ [0x00, 0x421c],
+ [0x00, 0x43ab],
+ [0x00, 0x4446],
+ [0x00, 0x4600],
+ [0x00, 0x4743],
+ [0x00, 0x4878],
+ [0x00, 0x4978],
+ [0x00, 0x4a78],
+ [0x00, 0x4b6d],
+ [0x00, 0x4c3c],
+ [0x00, 0x4d37],
+ [0x00, 0x4e7d]
+ );
+
+for my $arr (@list) {
+
+ # send_i2c_command($fpga, $addr, @$arr[0], @$arr[1], 0, 0, 1);
+ # printf("%x\n", @$arr[1]);
+}
--- /dev/null
+#!/usr/bin/perl
+
+use warnings;
+use lib "../";
+use Mimosis;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+
+my $fpga = 0xa000;
+
+my %vdac = (
+
+ 3 => 0x004c,
+
+ 4 => 0x0047,
+
+ 5 => 0x004d,
+
+ 7 => 0x0048,
+
+ 8 => 0x0049,
+
+ 9 => 0x004a,
+
+ 10 => 0x004b,
+);
+
+my %idac = (
+ 1 => 0x0040,
+ 2 => 0x0042,
+ 3 => 0x0041,
+);
+
+my %odac = (
+ 1 => 0x0045,
+ 2 => 0x0044,
+ 6 => 0x0043,
+);
+
+trb_init_ports() or die trb_strerror();
+
+my $vmon_file = "vmon_data.csv";
+my $imon_file = "imon_data.csv";
+my $other_file = "other_data.csv";
+
+open( v_FH, '>', $vmon_file ) or die $!;
+
+#MONVOLT
+for my $dac ( sort keys %vdac ) { #loop over voltage DACs
+
+ Mimosis::mimosis_register_write( $fpga, 0x0026, $dac );
+ usleep(1000);
+
+ for my $setv ( 0 .. 2**8 - 1 ) { #loop over settings
+
+ Mimosis::mimosis_register_write( $fpga, $vdac{$dac}, $setv );
+ usleep(10000);
+ Mimosis::adc_i2c_command( $fpga, 0x48, 0x01, 0xa380, 0, 0, 1 );
+ usleep(10000);
+ $volt_raw = Mimosis::adc_i2c_command( $fpga, 0x48, 0x0, 0x0, 1, 0, 1 );
+
+ # printf( "%x\t%i\t%i\n", $vdac{$dac}, $setv, $volt_raw );
+ printf( v_FH "%x\t%i\t%i\n", $vdac{$dac}, $setv, $volt_raw );
+ }
+
+ # printf("\n\n");
+ printf( v_FH "\n\n" );
+}
+
+close(v_FH);
+
+open( i_FH, '>', $imon_file ) or die $!;
+
+#MONCURR
+for my $dac ( sort keys %idac ) { #loop over current DACs
+
+ Mimosis::mimosis_register_write( $fpga, 0x0025, $dac );
+ usleep(1000);
+
+ for my $seti ( 0 .. 2**8 - 1 ) { #loop over settings
+
+ Mimosis::mimosis_register_write( $fpga, $idac{$dac}, $seti );
+ usleep(10000);
+ Mimosis::adc_i2c_command( $fpga, 0x48, 0x01, 0x9380, 0, 0, 1 );
+ usleep(10000);
+ $curr_raw = Mimosis::adc_i2c_command( $fpga, 0x48, 0x0, 0x0, 1, 0, 1 );
+
+ # printf( "%x\t%i\t%i\n", $idac{$dac}, $seti, $curr_raw );
+ printf( i_FH "%x\t%i\t%i\n", $idac{$dac}, $seti, $curr_raw );
+ }
+
+ # printf("\n\n");
+ printf( i_FH "\n\n" );
+}
+
+close(i_FH);
+open( o_FH, '>', $other_file ) or die $!;
+
+#MONVOLT_others
+for my $dac ( sort keys %odac ) {
+
+ Mimosis::mimosis_register_write( $fpga, 0x0026, $dac );
+ usleep(1000);
+
+ for my $setv ( 0 .. 2**8 - 1 ) { #loop over settings
+
+ Mimosis::mimosis_register_write( $fpga, $odac{$dac}, $setv );
+ usleep(10000);
+ Mimosis::adc_i2c_command( $fpga, 0x48, 0x01, 0xa380, 0, 0, 1 );
+ usleep(10000);
+ $volt_raw = Mimosis::adc_i2c_command( $fpga, 0x48, 0x0, 0x0, 1, 0, 1 );
+
+ # printf( "%x\t%i\t%i\n", $odac{$dac}, $setv, $volt_raw );
+ printf( o_FH "%x\t%i\t%i\n", $odac{$dac}, $setv, $volt_raw );
+ }
+
+ # printf("\n\n");
+ printf( o_FH "\n\n" );
+}
+
+close(o_FH);
+
+system("gnuplot -p plotdac.gp");
--- /dev/null
+set multiplot layout 1,3
+set title "VCASP, VCASNA, VCASNB, VCASNC,\nVCASND, VCASN2, VCLIP"
+# set title "VCASND"
+plot for [i=0:6] 'vmon_data.csv' using 2:3 index i with l notitle
+set title "IBIAS, ITHR, IDB"
+plot for [i=0:2] 'imon_data.csv' using 2:3 index i with l notitle
+set title "VRESET, VPH, VPL"
+plot for [i=0:2] 'other_data.csv' using 2:3 index i with l notitle
--- /dev/null
+#+title: Documentation
+#+author:
+#+date:
+#+OPTIONS: ^:{}
+
+
+* DAC Scan
+
+- Scan over all configurations of all DAC's, like in the [[file:/d/jspc37/mimosis/scripts/docu/mimosis1_i2c.pdf][docu]], Tab. 24, for verification of the functionality.
+- Scan will be made with an *ADS1115 ADC* conneted to a *TRB5sc* via an adapter board. Furthermore 3 cables will connect the *ADC* with the *proxy board* of the sensor. Make sure those components are available.
+
+** Instalation:
+
+ 1. If not already done, connect the *ADC* with the adapter board. The adapter board has 2 rows of pin header on its upper side. The *ADC* should be plugged into them in such a way, that the pins /GND/, /3V3/, /SDA/ and /SDC/ are all connected. You can verify it's plugged in correctly, if those 4 pins are now connected with a wire on the backside. Or with Figure [[adc]].
+ #+name: adc
+ #+caption: *ADC* facing inside the *TRB5sc*, wires facing to the left.
+ [[file:1.jpg]].
+
+ 2. If not already done, connect the adapter board with mounted *ADC* to the *TRB5sc*. Plug the pin header of the adapter board into the *JGPIO1* header of the *TRB5sc*, so that the *ADC* is facing inside the *TRB5sc*. Check Figure [[adc]].
+
+ 3. If not already done, connect 3 sufficiently long wires to the inputs, labled with /A0/, /A1/ and /A3/ of the terminal block of the *ADC*. Check Figure [[adc2]]:
+ #+name: adc2
+ #+caption: Three wires connected to the *ADC*.
+ [[file:3.jpg]].
+
+ 4. Connect the 3 wires with the *proxy board* in such a way, that /A3/ is connected to the /GND/ pin, /A0/ to the /IMON/ pin and /A1/ to the /VMON/ pin. You can find their locations at [[file:..]] or check Figure [[pb]].
+ #+name: pb
+ #+caption: View on the *proxy board* with the three wires connected to /GND/, /VMON/ and /IMON/.
+ [[file:pb.jpg]].
+
+** Procedure:
+
+ 1. If everything is connected and the boards are running, make sure the right software is at hand. You'll need:
+ - dac_scan.pl
+ - Mimosis.pm
+ - plotdac.pg
+ If you are not on jspc37 or another pc with the HADES perl libraries, make sure the dependencies in those files are met otherwise.
+
+ 2. Open a terminal, enter:
+ #+begin_src bash
+export DAQOPSERVER=jspc29:31
+ #+end_src
+
+ 3. Make sure dac_scan.pl and Mimosis.pm are in the same folder, for example /d/jspc37/mimosis/scripts/dac_scan/
+
+ 4. Execute
+ #+begin_src bash
+./dac_scan.pl | tee data.csv
+ #+end_src
+ or similar. You may want to change the name of the data file.
+
+ 5. When the command finishes, change the data-part in plotdac.gp to the right data file.
+
+ 6. Execute
+ #+begin_src bash
+gnuplot -p plotdac.gp
+ #+end_src
+ or similar.
--- /dev/null
+% Created 2022-11-23 Wed 16:07
+% Intended LaTeX compiler: pdflatex
+\documentclass[11pt]{article}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{wrapfig}
+\usepackage{rotating}
+\usepackage[normalem]{ulem}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{capt-of}
+\usepackage{hyperref}
+\date{}
+\title{Documentation}
+\hypersetup{
+ pdfauthor={},
+ pdftitle={Documentation},
+ pdfkeywords={},
+ pdfsubject={},
+ pdfcreator={Emacs 27.2 (Org mode 9.6)},
+ pdflang={English}}
+\usepackage{biblatex}
+
+\begin{document}
+
+\maketitle
+\tableofcontents
+
+
+
+\section{DAC Scan}
+\label{sec:org98c9b47}
+
+\begin{itemize}
+\item Scan over all configurations of all DAC's, like in the \href{file:///d/jspc37/mimosis/scripts/docu/mimosis1\_i2c.pdf}{docu}, Tab. 24, for verification of the functionality.
+\item Scan will be made with an \textbf{ADS1115 ADC} conneted to a \textbf{TRB5sc} via an adapter board. Furthermore 3 cables will connect the \textbf{ADC} with the \textbf{proxy board} of the sensor. Make sure those components are available.
+\end{itemize}
+
+\subsection{Instalation:}
+\label{sec:orgdcc122c}
+
+\begin{enumerate}
+\item If not already done, connect the \textbf{ADC} with the adapter board. The adapter board has 2 rows of pin header on its upper side. The \textbf{ADC} should be plugged into them in such a way, that the pins \emph{GND}, \emph{3V3}, \emph{SDA} and \emph{SDC} are all connected. You can verify it's plugged in correctly, if those 4 pins are now connected with a wire on the backside. Or with Figure \ref{adc}.
+\begin{figure}[htbp]
+\centering
+\includegraphics[width=.9\linewidth]{1.jpg}
+\caption{\label{adc}\textbf{ADC} facing inside the \textbf{TRB5sc}, wires facing to the left.}
+\end{figure}.
+
+\item If not already done, connect the adapter board with mounted \textbf{ADC} to the \textbf{TRB5sc}. Plug the pin header of the adapter board into the \textbf{JGPIO1} header of the \textbf{TRB5sc}, so that the \textbf{ADC} is facing inside the \textbf{TRB5sc}. Check Figure \ref{adc}.
+
+\item If not already done, connect 3 sufficiently long wires to the inputs, labled with \emph{A0}, \emph{A1} and \emph{A3} of the terminal block of the \textbf{ADC}. Check Figure \ref{adc2}:
+\begin{figure}[htbp]
+\centering
+\includegraphics[width=.9\linewidth]{3.jpg}
+\caption{\label{adc2}Three wires connected to the \textbf{ADC}.}
+\end{figure}.
+
+\item Connect the 3 wires with the \textbf{proxy board} in such a way, that \emph{A3} is connected to the \emph{GND} pin, \emph{A0} to the \emph{IMON} pin and \emph{A1} to the \emph{VMON} pin. You can find their locations at \url{..} or check Figure \ref{pb}.
+\begin{figure}[htbp]
+\centering
+\includegraphics[width=.9\linewidth]{pb.jpg}
+\caption{\label{pb}View on the \textbf{proxy board} with the three wires connected to \emph{GND}, \emph{VMON} and \emph{IMON}.}
+\end{figure}.
+\end{enumerate}
+
+\subsection{Procedure:}
+\label{sec:org11d8152}
+
+\begin{enumerate}
+\item If everything is connected and the boards are running, make sure the right software is at hand. You'll need:
+\begin{itemize}
+\item dac\_scan.pl
+\item Mimosis.pm
+\item plotdac.pg
+\end{itemize}
+If you are not on jspc37 or another pc with the HADES perl libraries, make sure the dependencies in those files are met otherwise.
+
+\item Open a terminal, enter:
+\begin{verbatim}
+export DAQOPSERVER=jspc29:31
+\end{verbatim}
+
+\item Make sure dac\_scan.pl and Mimosis.pm are in the same folder, for example \emph{d/jspc37/mimosis/scripts/dac\_scan}
+
+\item Execute
+\begin{verbatim}
+./dac_scan.pl | tee data.csv
+\end{verbatim}
+or similar. You may want to change the name of the data file.
+
+\item When the command finishes, change the data-part in plotdac.gp to the right data file.
+
+\item Execute
+\begin{verbatim}
+gnuplot -p plotdac.gp
+\end{verbatim}
+or similar.
+\end{enumerate}
+\end{document}
--- /dev/null
+% Created 2022-11-23 Wed 13:03
+% Intended LaTeX compiler: pdflatex
+\documentclass[presentation]{beamer}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{wrapfig}
+\usepackage{rotating}
+\usepackage[normalem]{ulem}
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{capt-of}
+\usepackage{hyperref}
+\usepackage{tikz}
+\usetheme{Malmoe}
+\date{}
+% \title{DAC Scan}
+\hypersetup{
+ pdfauthor={},
+ pdftitle={Presentation},
+ pdfkeywords={},
+ pdfsubject={},
+ pdfcreator={Emacs 27.2 (Org mode 9.6)},
+ pdflang={English}}
+\usepackage{biblatex}
+
+\begin{document}
+
+\begin{frame}[label={sec:org8c1536b}]{DAC Scan}
+\begin{itemize}
+ \item Scan over all configs of all DAC's using I2C and an ADC.
+ \item Adapter board for convenience.
+ \item Documentation available.
+\end{itemize}
+
+\vspace{3cm}
+
+\begin{tikzpicture}[remember picture, overlay]
+\node[below right] at (current page.west)
+{
+ \includegraphics[width=0.5\textwidth]{1.jpg}
+};
+\end{tikzpicture}
+
+\begin{tikzpicture}[remember picture, overlay]
+\node[below left] at (current page.east)
+{
+ \includegraphics[width=0.5\textwidth]{scan_3plots.png}
+};
+\end{tikzpicture}
+
+\end{frame}
+
+\begin{frame}[label={sec:org8c153db}]{DAC Scan}
+\begin{itemize}
+ \item Current limit reached during scan with basic settings.
+ \item Are there better settings?
+\end{itemize}
+
+\vspace{3cm}
+
+\begin{tikzpicture}[remember picture, overlay]
+\node[below right] at (current page.west)
+{
+ \includegraphics[width=0.5\textwidth]{scan_3plots_badcurve}
+};
+\end{tikzpicture}
+
+\begin{tikzpicture}[remember picture, overlay]
+\node[below left] at (current page.east)
+{
+ \includegraphics[width=0.5\textwidth]{scan_3plots_badcurve2}
+};
+
+\end{tikzpicture}
+
+\end{frame}
+
+\end{document}
--- /dev/null
+#!/usr/bin/perl -I.
+
+use warnings;
+use Getopt::Long;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+use lib ".";
+use Mimosis;
+
+my ($fpga, $addr, $cmd, $cmd_t, $data, $data_t, $word);
+
+Getopt::Long::Configure(qw(gnu_getopt));
+GetOptions(
+ "fpga|f=s" => \$fpga,
+ "addr|a=s" => \$addr,
+ "cmd|c=s" => \$cmd_t,
+ "data|d=s" => \$data_t,
+ "word|w" => \$word,
+ );
+
+trb_init_ports() or die trb_strerror();
+
+defined($fpga) ? $fpga = hex($fpga) : die print("Must provide FPGA address.\n");
+defined($addr) ? $addr = hex($addr) : die print("Must provide I2C address.\n");
+$cmd = defined($cmd_t) ? hex($cmd_t) : 0x0;
+$data = defined($data_t) ? hex($data_t) : 0x0;
+
+$val = Mimosis::send_i2c_command($fpga, $addr, $cmd, $data, !defined($data_t), !defined($cmd_t), defined($word));
+if(not defined($data_t)) {
+ printf("%x\n", $val);
+}
--- /dev/null
+#!/bin/bash
+
+
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2040 #'RUNMODE
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x216E #'TRIMDAC
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2200 #'INJCURR
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2300 #'INJVOLT
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2400 #'INJVOLT
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2500 #'MONCURR
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2600 #'MONVOLT
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2701 #'CLKGEN1
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2801 #'CLKGEN2
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2916 #'PLL'
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2a00 #'PLLLOCK
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2b00 #'MONTEMP
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2c15 #'SLVSTX'
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2d00 #'SLVSRX'
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2e17 #'OUTPUT'
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2f00 #'MONPWR'
+
+
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4040 #'IBIAS' : 64,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4134 #'ITHR' : 52,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x421c #'IDB' : 28,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x43ab #'VRESET' : 171,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4446 #'VPL' : 70,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4555 #'VPH' : 85,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4600 #'VPH_FINE' : 0,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4743 #'VCASP' : 67,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4878 #'VCASNA' : 1,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4978 #'VCASNB' : 1,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4a78 #'VCASNC' : 1,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4b6d #'VCASND' : 1,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4c3c #'VCASN2' : 83,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4d37 #'VCLIP' : 50,
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x4e7d #'IBUFBIAS' : 125
+
--- /dev/null
+#!/usr/bin/perl
+
+use Getopt::Long;
+use HADES::TrbNet;
+use Time::HiRes qw(usleep);
+
+Getopt::Long::Configure(qw(gnu_getopt));
+GetOptions(
+ "fpga|f=s" => \$fpga_t,
+ "addr|a=s" => \$addr_t,
+ "cmd|c=s" => \$cmd_t,
+ "data|d=s" => \$data_t,
+ "word|w" => \$word,
+ );
+
+trb_init_ports() or die trb_strerror();
+
+$fpga = defined($fpga_t) ? hex($fpga_t) : 0x0;
+$addr = defined($addr_t) ? hex($addr_t) : 0x0;
+$cmd = defined($cmd_t) ? hex($cmd_t) : 0x0;
+$data = defined($data_t) ? hex($data_t) : 0x0;
+
+$reg_data = ($data << 16) + ($cmd << 8) + ($addr << 1);
+$reg_flag = 0x110;
+
+if(not defined($fpga_t)) {
+ die print("Must provide FPGA address.\n");
+}
+
+if(defined($data_t) and defined($addr_t)) {
+ if(defined($cmd_t)) {
+ $reg_flag = $word == 1 ? 0x001 : 0x000;
+ }
+ elsif(not defined($cmd_t)) {
+ $reg_flag = $word == 1 ? 0x011 : 0x010;
+ }
+ trb_register_write_mem($fpga,0xde01,0,[$reg_flag,$reg_data,0x1],3);
+}
+elsif(not defined($data_t) and defined($addr_t)) {
+ trb_register_write_mem($fpga,0xde01,0,[$reg_flag,$reg_data,0x1],3);
+ usleep(1000);
+ $reg_return = trb_register_read($fpga,0xde04);
+ printf("%x\n", $reg_return->{$fpga});
+}
+
+# printf("%x\n", $reg_data);
+# printf("%x\n", $reg_flag);
--- /dev/null
+#!/bin/bash
+
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x40aa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x41fc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x42aa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x43fc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x44aa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x45fc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x46aa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x47fc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x48aa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x49fc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x4aaa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x4bfc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x4caa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x4dfc
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x4eaa
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x80 -d 0x4ffc
+
+./i2c_cmd2.pl -w 1 -f 0xa000 -a 0x12 -c 0x00 -d 0x2048
+
--- /dev/null
+#!/bin/bash
+
+## this script is called by conf.sh ##
+
+### set addresses of FPGAs ###
+
+trbcmd s 0x6c00000a62958028 0x01 0xc000
+trbcmd s 0x0000719900202941 0x01 0xa000
+
+
+
+echo "FPGAs after addressing"
+trbcmd i 0xffff
--- /dev/null
+
+
+
+!Register table
+# Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 # C9 #
+###################################################################################################
+ 0 0x8300 0x8305 0x8307 0x8308 0x830b
+ 1 0x8301 0x8302 0x8304 0x8309 0x830c 0x830e 0x830f 0x8310
+
+
+!Value table
+# SubEvtId UseGbE MultiQueue Trig. Num. InclTrgType
+# Hub # Type # C0 # C1 # C2 # C3 # C4 #
+##################################################################################
+ 0xc000 0 0xc000 1 0 0xffffff 1
+ 0xa000 0 0xa000 1 0 0xffffff 1
+
+
+
+#These values to not need to be written - for completeness only
+# SubEvtDec QueDec FrameSize RX enable SubEvtSize Evt/Queue QueueClose MaxQueueSize
+# Hub # Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 #
+##########################################################################################################################
+# 0xff7f 1 0x00020001 0x00030062 0x578 1 59800 200 32000 60000
+ 0xa000 1 0x00020009 0x00030062 0x578 1 59800 200 32000 60000
+
--- /dev/null
+###########################################################################################
+#Eventbuilders:
+# EB 0: hadespc001 eth1 ports 50000 - 50099
+
+!Register table
+# Type # C0 # C1 # C2 # C3 # C4 #
+#######################################################
+#new memory locations
+ 0 0x8100 0x8101 0x8102 0x8103 0x8107
+ 1 0x8110 0x8111 0x8112 0x8113 0x8117
+ 2 0x8120 0x8121 0x8122 0x8123 0x8127
+ 3 0x8130 0x8131 0x8132 0x8133 0x8137
+ 4 0x8140 0x8141 0x8142 0x8143 0x8147
+ 5 0x8150 0x8151 0x8152 0x8153 0x8157
+ 6 0x8160 0x8161 0x8162 0x8163 0x8167
+ 7 0x8170 0x8171 0x8172 0x8173 0x8177
+ 8 0x8180 0x8181 0x8182 0x8183 0x8187
+ 9 0x8190 0x8191 0x8192 0x8193 0x8197
+ 10 0x81A0 0x81A1 0x81A2 0x81A3 0x81A7
+ 11 0x81B0 0x81B1 0x81B2 0x81B3 0x81B7
+ 12 0x81C0 0x81C1 0x81C2 0x81C3 0x81C7
+ 13 0x81D0 0x81D1 0x81D2 0x81D3 0x81D7
+ 14 0x81E0 0x81E1 0x81E2 0x81E3 0x81E7
+ 15 0x81F0 0x81F1 0x81F2 0x81F3 0x81F7
+
+!Value table
+# Dest MAC Dest MAC Dest IP Dest Port Src Port
+# Hub # Type # C0 # C1 # C2 # C3 # C4 #
+####################################################################################
+
+ 0xc000 0 0xbacdb959 0x90e2 0xc0a80025 50301 0xc350
+ 0xa000 0 0xbacdb959 0x90e2 0xc0a80025 50302 0xc350
+
+
+
--- /dev/null
+#!/bin/bash
+export DAQOPSERVER=jspc29:31
+export PATH=$PATH:/local/trbsoft/trbnettools/bin/
+
+trbcmd reset
+
+./addresses.sh
+
+/d/jspc37/trbsoft/daqtools/tools/loadregisterdb.pl register_configgbe.db
+/d/jspc37/trbsoft/daqtools/tools/loadregisterdb.pl register_configgbe_ip.db
+sleep 1
+#./conf_cts.sh ### here you could call a cts settings dump ...
+#./conf_tdcs.sh
+
+trbcmd w 0xc000 0xa13b 0x000186a0 #1 kHz pulser
+trbcmd w 0xc000 0xa144 0x80 #use trigger type 8
+trbcmd clearbit 0xa000 0x22 0x80000000 #no ref time
+trbcmd w 0xa000 0x7111 0x2ee0 # max 12000 words
+
+#../scripts/basicsettings.sh
+
+trbcmd w 0xa000 0xa100 0x000 #enable word alignment
+sleep .2
+trbcmd setbit 0xa000 0xa100 0x100 #Word alignment off
+
+trbcmd w 0xa000 0xde00 30 #I2C speed
+trbcmd w 0xa000 0xde05 0x100 #Mimosis reset
+
+echo "done"
+