Skip to content
Snippets Groups Projects
Commit 2eac018e authored by Evan Paul Mladina's avatar Evan Paul Mladina
Browse files

Checks 1V4. If that works, reads AMAC values. Option to look at one board only.

parent 00aa3da1
No related branches found
No related tags found
3 merge requests!27Print status of AMAC/(Multiplexer) values for mass or single testbenches,!26Implement variable load scan on the mass tester active board,!24Active board multiplexer debug
Pipeline #1404319 failed
......@@ -28,12 +28,68 @@
//------ SETTINGS
loglevel_e loglevel = logINFO;
std::string configfile = "";
int pb=10;
//---------------
//------ Channel Map
std::map<std::string,AMACv2Field AMACv2Reg::*> channelmap={
{"VDCDC" ,&AMACv2::Ch0Value},
{"VDDLR" ,&AMACv2::Ch1Value},
{"DCDCin" ,&AMACv2::Ch2Value},
{"VDDREG" ,&AMACv2::Ch3Value},
{"sysBG" ,&AMACv2::Ch3Value},
{"AM900BG" ,&AMACv2::Ch3Value},
{"AM600BG" ,&AMACv2::Ch4Value},
{"CAL" ,&AMACv2::Ch4Value},
{"AMref" ,&AMACv2::Ch4Value},
{"CALx" ,&AMACv2::Ch5Value},
{"CALy" ,&AMACv2::Ch5Value},
{"Shuntx" ,&AMACv2::Ch5Value},
{"Shunty" ,&AMACv2::Ch5Value},
{"HGND" ,&AMACv2::Ch5Value},
{"DIETEMP" ,&AMACv2::Ch6Value},
{"NTCx" ,&AMACv2::Ch7Value},
{"NTCy" ,&AMACv2::Ch8Value},
{"NTCpb" ,&AMACv2::Ch9Value},
{"Hrefx" ,&AMACv2::Ch10Value},
{"Hrefy" ,&AMACv2::Ch11Value},
{"Cur10V" ,&AMACv2::Ch12Value},
{"Cur10VTPlow" ,&AMACv2::Ch12Value},
{"Cur10VTPhigh",&AMACv2::Ch12Value},
{"Cur1V" ,&AMACv2::Ch13Value},
{"Cur1VTPlow" ,&AMACv2::Ch13Value},
{"Cur1VTPhigh" ,&AMACv2::Ch13Value},
{"HVret" ,&AMACv2::Ch14Value},
{"PTAT" ,&AMACv2::Ch15Value},
};
std::map<std::string,std::pair<AMACv2Field AMACv2Reg::*, uint32_t> > muxmap={
{"VDDREG" ,{&AMACv2::Ch3Mux ,0}},
{"sysBG" ,{&AMACv2::Ch3Mux ,1}},
{"AM900BG" ,{&AMACv2::Ch3Mux ,2}},
{"AM600BG" ,{&AMACv2::Ch4Mux ,0}},
{"CAL" ,{&AMACv2::Ch4Mux ,1}},
{"AMref" ,{&AMACv2::Ch4Mux ,2}},
{"CALx" ,{&AMACv2::Ch5Mux ,0}},
{"CALy" ,{&AMACv2::Ch5Mux ,1}},
{"Shuntx" ,{&AMACv2::Ch5Mux ,2}},
{"Shunty" ,{&AMACv2::Ch5Mux ,3}},
{"HGND" ,{&AMACv2::Ch5Mux ,4}},
{"Cur10V" ,{&AMACv2::Ch12Mux,0}},
{"Cur10VTPlow" ,{&AMACv2::Ch12Mux,1}},
{"Cur10VTPhigh",{&AMACv2::Ch12Mux,2}},
{"Cur1V" ,{&AMACv2::Ch13Mux,0}},
{"Cur1VTPlow" ,{&AMACv2::Ch13Mux,1}},
{"Cur1VTPhigh" ,{&AMACv2::Ch13Mux,2}}
};
//---------------
void usage(char* argv[])
{
std::cerr << "Usage: " << argv[0] << " [options]" << std::endl;
std::cerr << "List of options:" << std::endl;
std::cerr << " -p, --powerboard Select specific powerboard" << std::endl;
std::cerr << " -d, --debug Enable more verbose printout" << std::endl;
std::cerr << "" << std::endl;
std::cerr << "" << std::endl;
......@@ -48,15 +104,19 @@ int main(int argc, char* argv[])
static struct option long_options[] =
{
{"debug" , no_argument , 0, 'd' },
{"pb" , required_argument, 0, 'p' },
{0 , 0 , 0, 0 }
};
c = getopt_long(argc, argv, "c:r:b:h:d", long_options, &option_index);
c = getopt_long(argc, argv, "p:c:r:b:h:d", long_options, &option_index);
if (c == -1)
break;
switch (c)
{
case 'p':
pb = std::stoi(optarg);
break;
case 'd':
loglevel = logDEBUG;
break;
......@@ -106,24 +166,161 @@ int main(int argc, char* argv[])
return 1;
}
std::cout << "\t" << "Linpol1V4" << "\t" << "Linpol3V3" << "\t" << "Vout" << "\t" << "OFout" << "\t" << "ShuntX" << "\t" << "ShuntY" << "\t" << "LDx0EN" << "\t" << "LDx1EN" << "\t" << "LDx2EN" << "\t" << "LDy0EN" << "\t" << "LDy1EN" << "\t" << "LDy2EN" << std::endl;
std::shared_ptr<AMACv2> amac[10];
json config[10];
double LP1V4;
double LP3V3;
double Vout;
double OFout;
double Shuntx;
double Shunty;
double LDx0EN;
double LDx1EN;
double LDx2EN;
double LDy0EN;
double LDy1EN;
double LDy2EN;
for(uint32_t i=0;i<10;i++) {
int max;
int i;
if(pb==10) {
i=0;
max=10;
}
else {
i=pb;
max=pb+1;
}
for(i;i<max;i++) {
LP1V4 = tb->readCarrierOutput(i, PBv3TBMassive::LINPOL1V4);
LP3V3 = tb->readCarrierOutput(i, PBv3TBMassive::LINPOL3V3);
if(LP1V4 > 1.3 && LP1V4 < 1.5) {
logger(logINFO) << "PB " << i << ": linPOL 1V4 reading " << LP1V4 << ". Checking AMAC values.";
//Init Com
if(!configfile.empty())
{
std::ifstream fh_in(configfile);
if(fh_in.is_open())
fh_in >> config[i];
}
logger(logINFO) << "Init AMAC for PB " << i << ".";
amac[i] = tb->getPB(i);
try {
amac[i]->init();
PBv3ConfigTools::configAMAC(amac[i], config[i], false);
amac[i]->initRegisters();
PBv3ConfigTools::saveConfigAMAC(amac[i], config[i]);
} catch(EndeavourComException &e) {
logger(logERROR) << "Unable to initialize AMACv2";
logger(logERROR) << e.what();
logger(logINFO) << "Turning off power supply.";
ps.turnOff();
return 1;
}
std::this_thread::sleep_for(std::chrono::milliseconds(500));
AMACv2Field AMACv2Reg::* ch;
for(int chNum = 0; chNum < 16; chNum++) {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
switch(chNum)
{
case 0:
ch=&AMACv2::Ch0Value;
std::cout << "VDCDC: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 1:
ch=&AMACv2::Ch1Value;
std::cout << "VDDLR: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 2:
ch=&AMACv2::Ch2Value;
std::cout << "DCDCin: " << "\t" << amac[i]->rdField(ch) << std::endl;
break;
case 3:
ch=&AMACv2::Ch3Value;
amac[i]->wrField(muxmap["VDDREG"].first,muxmap["VDDREG"].second);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "VDDREG: " << "\t" << amac[i]->rdField(ch) << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
amac[i]->wrField(muxmap["AM900BG"].first,muxmap["AM900BG"].second);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "AM900BG: " << "\t" << amac[i]->rdField(ch) << std::endl;
break;
case 4:
ch=&AMACv2::Ch4Value;
std::cout << "AM600BG: " << "\t" << amac[i]->rdField(ch) << std::endl;
break;
case 5:
ch=&AMACv2::Ch5Value;
amac[i]->wrField(muxmap["Shuntx"].first,muxmap["Shuntx"].second);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "Shuntx: " << "\t" << amac[i]->rdField(ch) << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
amac[i]->wrField(muxmap["Shunty"].first,muxmap["Shunty"].second);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "Shunty: " << "\t" << amac[i]->rdField(ch) << std::endl;
break;
case 6:
ch=&AMACv2::Ch6Value;
std::cout << "DIETEMP: " << "\t" << amac[i]->rdField(ch) << std::endl;
break;
case 7:
ch=&AMACv2::Ch7Value;
std::cout << "NTCx: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 8:
ch=&AMACv2::Ch8Value;
std::cout << "NTCy: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 9:
ch=&AMACv2::Ch9Value;
std::cout << "NTCpb: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 10:
ch=&AMACv2::Ch10Value;
std::cout << "Hrefx: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 11:
ch=&AMACv2::Ch11Value;
std::cout << "Hrefy: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 12:
ch=&AMACv2::Ch12Value;
amac[i]->wrField(muxmap["Cur10V"].first,muxmap["Cur10V"].second);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "Cur10V: " << "\t" << amac[i]->rdField(ch) << std::endl;
break;
case 13:
ch=&AMACv2::Ch13Value;
amac[i]->wrField(muxmap["Cur1V"].first,muxmap["Cur1V"].second);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << "Cur1V: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 14:
ch=&AMACv2::Ch14Value;
std::cout << "HVret: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
case 15:
ch=&AMACv2::Ch15Value;
std::cout << "PTAT: " << "\t\t" << amac[i]->rdField(ch) << std::endl;
break;
default:
std::cerr << "Channel must be in range 0-15." << std::endl;
usage(argv);
return 1;
}
}
}
else {
logger(logWARNING) << "PB " << i << ": linPOL 1V4 reading " << LP1V4 << ".";
}
}
logger(logINFO) << "Turning off power supply.";
ps.turnOff();
return 0;
}
/*
std::cout << i << "\t" << LP1V4 << "\t" << LP3V3 << "\t" << Vout << "\t" << OFout << "\t" << Shuntx << "\t" << Shunty << "\t" << LDx0EN << "\t" << LDx1EN<< "\t" << LDx2EN << "\t" << LDy0EN << "\t" << LDy1EN << "\t" << LDy2EN << std::endl;
*
* LP3V3 = tb->readCarrierOutput(i, PBv3TBMassive::LINPOL3V3);
Vout = tb->readCarrierOutput(i, PBv3TBMassive::VOUT );
OFout = tb->readCarrierOutput(i, PBv3TBMassive::OFout );
Shuntx = tb->readCarrierOutput(i, PBv3TBMassive::SHUNTx );
......@@ -134,8 +331,4 @@ int main(int argc, char* argv[])
LDy0EN = tb->readCarrierOutput(i, PBv3TBMassive::LDy0EN );
LDy1EN = tb->readCarrierOutput(i, PBv3TBMassive::LDy1EN );
LDy2EN = tb->readCarrierOutput(i, PBv3TBMassive::LDy2EN );
std::cout << i << "\t" << LP1V4 << "\t" << LP3V3 << "\t" << Vout << "\t" << OFout << "\t" << Shuntx << "\t" << Shunty << "\t" << LDx0EN << "\t" << LDx1EN<< "\t" << LDx2EN << "\t" << LDy0EN << "\t" << LDy1EN << "\t" << LDy2EN << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
return 0;
}
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment