From: Jan Michel Date: Tue, 29 Nov 2022 11:32:04 +0000 (+0100) Subject: initial commit X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=e22c7479865f79a74f65f35270f3408ac9e96d95;p=mimosis_chain.git initial commit --- e22c7479865f79a74f65f35270f3408ac9e96d95 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22ca6d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*snm +*toc +*nav +*run.xml +*bcf +*aux +*out +*log +scratch diff --git a/analysis/rawreader/first.C b/analysis/rawreader/first.C new file mode 100644 index 0000000..c7342dd --- /dev/null +++ b/analysis/rawreader/first.C @@ -0,0 +1,63 @@ +// this is example for + +#include + +#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;kNumberOfTRB();k++) { + hadaq::TrbProcessor* trb = hld->GetTRB(k); + if (trb==0) continue; + + + printf("Configure %s!\n", trb->GetName()); + trb->SetPrintErrors(10); + } + + +} + + diff --git a/analysis/rawreader/mimosis.h b/analysis/rawreader/mimosis.h new file mode 100644 index 0000000..42709a4 --- /dev/null +++ b/analysis/rawreader/mimosis.h @@ -0,0 +1,156 @@ +#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 (;n6) { + 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 diff --git a/analysis/rawreader/second.C b/analysis/rawreader/second.C new file mode 100644 index 0000000..8d4ae19 --- /dev/null +++ b/analysis/rawreader/second.C @@ -0,0 +1,266 @@ +#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 (ev->GetSubEvent(fTdcId)); + if (!sub) { + printf("Fail to find %s\n", fTdcId.c_str()); + return false; + } + + hadaq::HldSubEvent *hld = dynamic_cast (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;ihitSize();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;ihitSize();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;ihitSize();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"); +} + + + + diff --git a/dabc/EventBuilder.xml b/dabc/EventBuilder.xml new file mode 100644 index 0000000..89e8e20 --- /dev/null +++ b/dabc/EventBuilder.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/CONF_allregisters.pl b/scripts/CONF_allregisters.pl new file mode 100644 index 0000000..3b1078c --- /dev/null +++ b/scripts/CONF_allregisters.pl @@ -0,0 +1,135 @@ +#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 + diff --git a/scripts/Mimosis.pm b/scripts/Mimosis.pm new file mode 100644 index 0000000..02d025d --- /dev/null +++ b/scripts/Mimosis.pm @@ -0,0 +1,108 @@ +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__ diff --git a/scripts/basicsettings.pl b/scripts/basicsettings.pl new file mode 100755 index 0000000..1f028c5 --- /dev/null +++ b/scripts/basicsettings.pl @@ -0,0 +1,48 @@ +#!/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]); +} diff --git a/scripts/dac_scan/dac_scan.pl b/scripts/dac_scan/dac_scan.pl new file mode 100755 index 0000000..67f898e --- /dev/null +++ b/scripts/dac_scan/dac_scan.pl @@ -0,0 +1,123 @@ +#!/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"); diff --git a/scripts/dac_scan/plotdac.gp b/scripts/dac_scan/plotdac.gp new file mode 100755 index 0000000..bebce09 --- /dev/null +++ b/scripts/dac_scan/plotdac.gp @@ -0,0 +1,8 @@ +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 diff --git a/scripts/docu/dac_scan/1.jpg b/scripts/docu/dac_scan/1.jpg new file mode 100644 index 0000000..b11f85f Binary files /dev/null and b/scripts/docu/dac_scan/1.jpg differ diff --git a/scripts/docu/dac_scan/2.jpg b/scripts/docu/dac_scan/2.jpg new file mode 100644 index 0000000..5b592b4 Binary files /dev/null and b/scripts/docu/dac_scan/2.jpg differ diff --git a/scripts/docu/dac_scan/3.jpg b/scripts/docu/dac_scan/3.jpg new file mode 100644 index 0000000..a256667 Binary files /dev/null and b/scripts/docu/dac_scan/3.jpg differ diff --git a/scripts/docu/dac_scan/DOCU.org b/scripts/docu/dac_scan/DOCU.org new file mode 100644 index 0000000..51bf129 --- /dev/null +++ b/scripts/docu/dac_scan/DOCU.org @@ -0,0 +1,58 @@ +#+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. diff --git a/scripts/docu/dac_scan/DOCU.pdf b/scripts/docu/dac_scan/DOCU.pdf new file mode 100644 index 0000000..dabee0c Binary files /dev/null and b/scripts/docu/dac_scan/DOCU.pdf differ diff --git a/scripts/docu/dac_scan/DOCU.tex b/scripts/docu/dac_scan/DOCU.tex new file mode 100644 index 0000000..b5fb1b3 --- /dev/null +++ b/scripts/docu/dac_scan/DOCU.tex @@ -0,0 +1,102 @@ +% 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} diff --git a/scripts/docu/dac_scan/PRESENTATION.pdf b/scripts/docu/dac_scan/PRESENTATION.pdf new file mode 100644 index 0000000..e7540ea Binary files /dev/null and b/scripts/docu/dac_scan/PRESENTATION.pdf differ diff --git a/scripts/docu/dac_scan/PRESENTATION.tex b/scripts/docu/dac_scan/PRESENTATION.tex new file mode 100644 index 0000000..0e55fbf --- /dev/null +++ b/scripts/docu/dac_scan/PRESENTATION.tex @@ -0,0 +1,80 @@ +% 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} diff --git a/scripts/docu/dac_scan/pb.jpg b/scripts/docu/dac_scan/pb.jpg new file mode 100644 index 0000000..30a769e Binary files /dev/null and b/scripts/docu/dac_scan/pb.jpg differ diff --git a/scripts/docu/dac_scan/scan_3plots.png b/scripts/docu/dac_scan/scan_3plots.png new file mode 100644 index 0000000..2c78d0b Binary files /dev/null and b/scripts/docu/dac_scan/scan_3plots.png differ diff --git a/scripts/docu/dac_scan/scan_3plots_badcurve.png b/scripts/docu/dac_scan/scan_3plots_badcurve.png new file mode 100644 index 0000000..8839c4c Binary files /dev/null and b/scripts/docu/dac_scan/scan_3plots_badcurve.png differ diff --git a/scripts/docu/dac_scan/scan_3plots_badcurve2.png b/scripts/docu/dac_scan/scan_3plots_badcurve2.png new file mode 100644 index 0000000..d954ea4 Binary files /dev/null and b/scripts/docu/dac_scan/scan_3plots_badcurve2.png differ diff --git a/scripts/docu/dac_scan/scan_3plots_basicsettings.png b/scripts/docu/dac_scan/scan_3plots_basicsettings.png new file mode 100644 index 0000000..0494fb5 Binary files /dev/null and b/scripts/docu/dac_scan/scan_3plots_basicsettings.png differ diff --git a/scripts/i2c_cmd.pl b/scripts/i2c_cmd.pl new file mode 100755 index 0000000..8d9730b --- /dev/null +++ b/scripts/i2c_cmd.pl @@ -0,0 +1,31 @@ +#!/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); +} diff --git a/scripts/legacy/basicsettings.sh b/scripts/legacy/basicsettings.sh new file mode 100755 index 0000000..c3a4f66 --- /dev/null +++ b/scripts/legacy/basicsettings.sh @@ -0,0 +1,37 @@ +#!/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 + diff --git a/scripts/legacy/i2c_cmd2.pl b/scripts/legacy/i2c_cmd2.pl new file mode 100755 index 0000000..76c680c --- /dev/null +++ b/scripts/legacy/i2c_cmd2.pl @@ -0,0 +1,47 @@ +#!/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); diff --git a/scripts/testmode_enable.sh b/scripts/testmode_enable.sh new file mode 100755 index 0000000..a82a639 --- /dev/null +++ b/scripts/testmode_enable.sh @@ -0,0 +1,21 @@ +#!/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 + diff --git a/trbnet/addresses.sh b/trbnet/addresses.sh new file mode 100755 index 0000000..e6b4132 --- /dev/null +++ b/trbnet/addresses.sh @@ -0,0 +1,13 @@ +#!/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 diff --git a/trbnet/register_configgbe.db b/trbnet/register_configgbe.db new file mode 100644 index 0000000..9fb3022 --- /dev/null +++ b/trbnet/register_configgbe.db @@ -0,0 +1,26 @@ + + + +!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 + diff --git a/trbnet/register_configgbe_ip.db b/trbnet/register_configgbe_ip.db new file mode 100644 index 0000000..5eab02f --- /dev/null +++ b/trbnet/register_configgbe_ip.db @@ -0,0 +1,35 @@ +########################################################################################### +#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 + + + diff --git a/trbnet/start.sh b/trbnet/start.sh new file mode 100755 index 0000000..9864be4 --- /dev/null +++ b/trbnet/start.sh @@ -0,0 +1,30 @@ +#!/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" +