diff --git a/Examples/usbgse3/gsetest b/Examples/usbgse3/gsetest index 3837ab4..a4aa69e 100755 Binary files a/Examples/usbgse3/gsetest and b/Examples/usbgse3/gsetest differ diff --git a/Examples/usbgse3/gsetest.cpp b/Examples/usbgse3/gsetest.cpp index a916987..b352cb1 100644 --- a/Examples/usbgse3/gsetest.cpp +++ b/Examples/usbgse3/gsetest.cpp @@ -1,353 +1,424 @@ -//------------------------------------------------------------------------ -// gsetest.cpp -// -// Written by Stephen McBride -// -// -//------------------------------------------------------------------------ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "okFrontPanelDLL.h" - -using namespace std; - -//define the number of threads that we will create in this example -#define NUM_THREADS 8 - -#define MAXPATH 128 -#define CONFIGURATION_FILE "gsesync.bit" - -extern int errno; -struct tm *times; -time_t ltime; -char obsfilespec[MAXPATH]; - -okCFrontPanel *dev; - -// set up phase lock loop -// load FPGA code - -okCFrontPanel *initializeFPGA() -{ - bool bresult; - // Open the first XEM - try all board types. - dev = new okCFrontPanel; - if (okCFrontPanel::NoError != dev->OpenBySerial()) { - delete dev; - printf("Device could not be opened. Is one connected?\n"); - return(NULL); - } - - switch (dev->GetBoardModel()) { - case okCFrontPanel::brdXEM3005: - printf(" Found a device: XEM3005\n"); - break; - default: - printf("Unsupported device.\n"); - delete dev; - return(NULL); - } - - - // Configure the PLL appropriately - okCPLL22150 *pll = new okCPLL22150 ; - pll->SetReference(48.0f, false); - bresult = pll->SetVCOParameters(574, 105); // output 32 x 8.2 MHz - close to 8.192 MHz - //cout << "Settin VCO Parameters " << bresult << endl; - pll->SetDiv1(okCPLL22150::DivSrc_VCO, 8); - // 32.8 approcimately 16 x 2.048 MHz - pll->SetDiv2(okCPLL22150::DivSrc_VCO, 127); - pll->SetOutputSource(0, okCPLL22150::ClkSrc_Div2By2); // Xilinx pin A8 = SYS_CLK1 (clk1) - pll->SetOutputEnable(0, true); - pll->SetOutputSource(1, okCPLL22150::ClkSrc_Div1ByN); // Xilinx pin A8 = SYS_CLK1 (clk1) - pll->SetOutputEnable(1, true); - pll->SetOutputSource(2, okCPLL22150::ClkSrc_Div1ByN); // Xilinx pin E9 = SYS_CLK2 (clk2) - pll->SetOutputEnable(2, true); - pll->SetOutputSource(3, okCPLL22150::ClkSrc_Div1ByN); // p71 = SYS_CLK4 - pll->SetOutputEnable(3, true); - pll->SetOutputSource(4, okCPLL22150::ClkSrc_Div1ByN); // p69 = SYS_CLK5 - pll->SetOutputEnable(4, true); - pll->SetOutputSource(5, okCPLL22150::ClkSrc_Div2ByN); //p67 = SYS_CLK6 - pll->SetOutputEnable(5, true); - dev->SetPLL22150Configuration(*pll); - // Get some general information about the XEM. - printf(" Device firmware version: %d.%d\n", dev->GetDeviceMajorVersion(), dev->GetDeviceMinorVersion()); - printf(" Device serial number: %s\n", dev->GetSerialNumber().c_str()); - printf(" Device ID string: %s\n", dev->GetDeviceID().c_str()); - - // Download the configuration file. - if (okCFrontPanel::NoError != dev->ConfigureFPGA(CONFIGURATION_FILE)) { - printf("FPGA configuration failed.\n"); - delete dev; - return(NULL); - } - - // Check for FrontPanel support in the FPGA configuration. - if (false == dev->IsFrontPanelEnabled()) { - printf(" FrontPanel support is not enabled.\n"); - delete dev; - return(NULL); - } - - printf(" FrontPanel support is enabled.\n"); - - return(dev); -} - -char hexnib(int hexval) -{ - hexval &= 0xf; - if( hexval < 10) return( hexval + 0x30); - else return(hexval + 0x37); - -} - -void toihex(char * s, unsigned short int v) -{ - *s++ = hexnib( (v >> 12) & 0xf); - *s++ = hexnib( (v >> 8) & 0xf); - *s++ = hexnib( (v >> 4) & 0xf); - *s++ = hexnib( v & 0xf); - *s++ = 0; -} - -void printframe(unsigned short int * buf) -{ - int i,j; - char s[80]; - printf("\033[0;0H"); - for(i = 0; i < 64; i++) - { - for (j = 0; j < 16; j++) - { - toihex(s , *buf++); - printf("%s ",s); - } - printf("\n"); - } -} - -unsigned short int buffer0[1024],buffer1[1024]; -unsigned short int buffer[1024]; -pthread_mutex_t mymutex; - -int fout; -int newdisplay; - -void *readgse(void *threadid) -{ - unsigned int i; - long len; - ssize_t wlen; - unsigned short int status; - - //??? never ending loop? - for(i=0;;i++) - { - //??? in the following code looks like it reads two frames of data - // first time it writes it to a file then places it in memory - // second time, it does it in the opposite order. why? - // - // alternate between reading data into buffer0 and buffer1 - // copy it into buffer with memcopy - - len = dev->ReadFromBlockPipeOut(0xA0,1024,2048,(unsigned char *) buffer0); - - if(fout >0) - { - if( (wlen = write(fout,(const void *) buffer0,2048) ) != 2048){}; - } - - if (pthread_mutex_trylock(&mymutex) == 0) /* if fail missed as main hasn't finished */ - { - if(newdisplay == 0) - { - memcpy((void *) buffer,(void *) buffer0,2048); - newdisplay = 1; - } - pthread_mutex_unlock(&mymutex); - - } - - len = dev->ReadFromBlockPipeOut(0xA0,1024,2048,(unsigned char *) buffer1); - - if (pthread_mutex_trylock(&mymutex) == 0) /* if fail missed as main hasn't finished */ - { - memcpy((void *) buffer,(void *) buffer1,2048); - pthread_mutex_unlock(&mymutex); - } - - if(fout >0) - { - if( (wlen = write(fout,(const void *) buffer1,2048) ) != 2048){}; - } - } -} - - -void Startfile() -{ - // Open a file to write the data to - // file pointer is set to fout - char stringtemp[80]; - time(<ime); - times = localtime(<ime); - strftime(stringtemp,23,"data_%y%m%d_%H%M.dat",times); - strncpy(obsfilespec,stringtemp,MAXPATH - 1); - obsfilespec[MAXPATH - 1] = '\0'; - printf("%s \r",obsfilespec); - { - if((fout = open(obsfilespec,O_RDWR|O_CREAT,0600)) < 0) - printf("Cannot open file\n"); - } -} - -int displayonce,displaycont; -char inbuffer[80]; - -void *charcommand(void *threadid) -{ - // ??? not sure what the purpose of this function. - int mychar; - if(setvbuf(stdin,(char *) NULL,_IONBF,0) != 0) printf("Didn't set buffer\n"); - // infinite loop - for(;;) - { - mychar = getchar(); - if( (mychar == 'c') || (mychar == 'C') ) - { - if( displaycont != 0) displaycont = 0; - else displaycont = 1; - } - if((mychar == 'd') || (mychar == 'D')) - { - displayonce = 1; - } - if((mychar == 'f') || (mychar == 'F')) - { - if(fout <= 0) - { - printf(" Opening "); - Startfile(); - } - else - { - printf(" Closing %s \r",obsfilespec); - close(fout); - fout = 0; - } - } - if(mychar == 0xa) printf("\033[1A"); - } -} - -int main(int argc, char *argv[]) -{ - - char dll_date[32], dll_time[32]; - char waitnum; - int nofile; - char *parseptr; - pthread_t threads[NUM_THREADS]; - struct sched_param param; - pthread_attr_t tattr; - - int *taskids[NUM_THREADS]; - int ret, t; - - displayonce = 0; - displaycont = 1; - - // define the custom priority for one of the threads - int newprio = -10; - // define the thread that will get the custom priority - int prioid = 0; - - param.sched_priority = newprio; - ret = pthread_attr_init(&tattr); - - // set the new scheduling param - ret = pthread_attr_setschedparam (&tattr, ¶m); - - printf("\033[2J \033[65;0H ---- FOXSI gse setup ----\n"); - if (FALSE == okFrontPanelDLL_LoadLib(NULL)) - { - printf("FrontPanel DLL could not be loaded.\n"); - return(-1); - } - okFrontPanelDLL_GetVersion(dll_date, dll_time); - printf(" FrontPanel DLL loaded.Built: %s %s\n", dll_date, dll_time); - - // parse argument list passed on execution - // only arg is can accept is "-n" which means do not write to file - while (argc > 1) - { - ++argv; - parseptr = *argv; - if(*parseptr == '-') - { - if(*(parseptr + 1) == 'n') nofile = 1; - } - argc--; - } - - // Initialize the FPGA with our configuration bitfile. - okCFrontPanel *devi = initializeFPGA(); - if (NULL == devi) - { - printf("FPGA could not be initialized.\n"); - return(-1); - } - - fout = 0; - printf("\033[65;0H "); - if( nofile == 0) - { - printf(" Opening "); - Startfile(); - } - - if (NULL != devi) - { - - ret = pthread_create(&threads[0], &tattr, readgse, (void *) taskids[0]); - pthread_mutex_init(&mymutex,NULL); - ret = pthread_create(&threads[0], NULL, charcommand, (void *) taskids[1]); - - } - - // infinite loop which checks buffer and prints it to the screen if needed. - for(;;) - { - if( newdisplay == 1) - { - pthread_mutex_lock( &mymutex); /* wait on readgse */ - if((displayonce != 0) || (displaycont != 0)) - { - displayonce = 0; - printframe(buffer); - newdisplay = 0; - fflush(stdout); - } - pthread_mutex_unlock(&mymutex); - } - - } - - return(0); -} +//------------------------------------------------------------------------ +// gsetest.cpp +// +// +// +//------------------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "okFrontPanelDLL.h" + +using namespace std; + +//define the number of threads that we will create in this example +#define NUM_THREADS 8 + +#define MAXPATH 128 +#define CONFIGURATION_FILE "gsesync.bit" + +extern int errno; +struct tm *times; +time_t ltime; +char obsfilespec[MAXPATH]; +float Tref,V5V,VM5V,V33V,V15V; +float T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11; +unsigned short int hkp[16],frameno,subcom,*bufptr; +float therm(unsigned short int ); + + +okCFrontPanel *dev; + +// set up phase lock loop +// load FPGA code + +okCFrontPanel * +initializeFPGA() +{ + bool bresult; + // Open the first XEM - try all board types. + dev = new okCFrontPanel; + if (okCFrontPanel::NoError != dev->OpenBySerial()) { + delete dev; + printf("Device could not be opened. Is one connected?\n"); + return(NULL); + } + + switch (dev->GetBoardModel()) { + case okCFrontPanel::brdXEM3005: + printf(" Found a device: XEM3005\n"); + break; + default: + printf("Unsupported device.\n"); + delete dev; + return(NULL); + } + + + // Configure the PLL appropriately + okCPLL22150 *pll = new okCPLL22150 ; + pll->SetReference(48.0f, false); + bresult = pll->SetVCOParameters(574, 105); // output 32 x 8.2 MHz - close to 8.192 MHz + //cout << "Settin VCO Parameters " << bresult << endl; + pll->SetDiv1(okCPLL22150::DivSrc_VCO, 8); +// 32.8 approcimately 16 x 2.048 MHz + pll->SetDiv2(okCPLL22150::DivSrc_VCO, 127); + pll->SetOutputSource(0, okCPLL22150::ClkSrc_Div2By2); // Xilinx pin A8 = SYS_CLK1 (clk1) + pll->SetOutputEnable(0, true); + pll->SetOutputSource(1, okCPLL22150::ClkSrc_Div1ByN); // Xilinx pin A8 = SYS_CLK1 (clk1) + pll->SetOutputEnable(1, true); + pll->SetOutputSource(2, okCPLL22150::ClkSrc_Div1ByN); // Xilinx pin E9 = SYS_CLK2 (clk2) + pll->SetOutputEnable(2, true); + pll->SetOutputSource(3, okCPLL22150::ClkSrc_Div1ByN); // p71 = SYS_CLK4 + pll->SetOutputEnable(3, true); + pll->SetOutputSource(4, okCPLL22150::ClkSrc_Div1ByN); // p69 = SYS_CLK5 + pll->SetOutputEnable(4, true); + pll->SetOutputSource(5, okCPLL22150::ClkSrc_Div2ByN); //p67 = SYS_CLK6 + pll->SetOutputEnable(5, true); + dev->SetPLL22150Configuration(*pll); + // Get some general information about the XEM. + printf(" Device firmware version: %d.%d\n", dev->GetDeviceMajorVersion(), dev->GetDeviceMinorVersion()); + printf(" Device serial number: %s\n", dev->GetSerialNumber().c_str()); + printf(" Device ID string: %s\n", dev->GetDeviceID().c_str()); + + // Download the configuration file. + if (okCFrontPanel::NoError != dev->ConfigureFPGA(CONFIGURATION_FILE)) { + printf("FPGA configuration failed.\n"); + delete dev; + return(NULL); + } + + // Check for FrontPanel support in the FPGA configuration. + if (false == dev->IsFrontPanelEnabled()) { + printf(" FrontPanel support is not enabled.\n"); + delete dev; + return(NULL); + } + + printf(" FrontPanel support is enabled.\n"); + + return(dev); +} + +char hexnib(int hexval) +{ + hexval &= 0xf; + if( hexval < 10) return( hexval + 0x30); + else return(hexval + 0x37); + +} + +void toihex(char * s, unsigned short int v) +{ + *s++ = hexnib( (v >> 12) & 0xf); + *s++ = hexnib( (v >> 8) & 0xf); + *s++ = hexnib( (v >> 4) & 0xf); + *s++ = hexnib( v & 0xf); + *s++ = 0; +} + +void printframe(unsigned short int * buf) +{ + int i,j; + char s[80]; + printf("\033[0;0H"); + for(i = 0; i < 64; i++) + { + for (j = 0; j < 16; j++) + { + toihex(s , *buf++); + printf("%s ",s); + } + printf("\n"); + } +} + +unsigned short int buffer0[1024],buffer1[1024]; +unsigned short int buffer[1024]; +pthread_mutex_t mymutex; + +int fout; +int newdisplay; + +void +*readgse(void *threadid) +{ +unsigned int i; +long len; +ssize_t wlen; +unsigned short int status; + + for(i=0;;i++) + { + + + len = dev->ReadFromBlockPipeOut(0xA0,1024,2048,(unsigned char *) buffer0); + if(fout >0) + { + if( (wlen = write(fout,(const void *) buffer0,2048) ) != 2048){}; + } + if (pthread_mutex_trylock(&mymutex) == 0) /* if fail missed as main hasn't finished */ + { + if(newdisplay == 0) + { + memcpy((void *) buffer,(void *) buffer0,2048); + newdisplay = 1; + } + pthread_mutex_unlock(&mymutex); + + } + len = dev->ReadFromBlockPipeOut(0xA0,1024,2048,(unsigned char *) buffer1); + if (pthread_mutex_trylock(&mymutex) == 0) /* if fail missed as main hasn't finished */ + { + memcpy((void *) buffer,(void *) buffer1,2048); + pthread_mutex_unlock(&mymutex); + + } + if(fout >0) + { + if( (wlen = write(fout,(const void *) buffer1,2048) ) != 2048){}; + } + } +} + + +void Startfile() +{ + char stringtemp[80]; + time(<ime); + times = localtime(<ime); + strftime(stringtemp,25,"data_%y%m%d_%H%M%S.dat",times); + strncpy(obsfilespec,stringtemp,MAXPATH - 1); + obsfilespec[MAXPATH - 1] = '\0'; + printf("%s \r",obsfilespec); + { + if((fout = open(obsfilespec,O_RDWR|O_CREAT,0600)) < 0) + printf("Cannot open file\n"); + } + +} +int showhkp; +int displayonce,displaycont; +char inbuffer[80]; + +void +*charcommand(void *threadid) +{ +int mychar; +if(setvbuf(stdin,(char *) NULL,_IONBF,0) != 0) printf("Didn't set buffer\n"); +for(;;) +{ + mychar = getchar(); + if( (mychar == 'c') || (mychar == 'C') ) + { + if( displaycont != 0) displaycont = 0; + else displaycont = 1; + } + if((mychar == 'd') || (mychar == 'D')) + { + displayonce = 1; + } + if((mychar == 'f') || (mychar == 'F')) + { + if(fout <= 0) + { + printf(" Opening "); + Startfile(); + } + else + { + printf(" Closing %s \r",obsfilespec); + close(fout); + fout = 0; + } + } + if((mychar == 'h') || (mychar == 'H')) + { + if(showhkp != 0) showhkp = 0; + else showhkp = 1; + } + if(mychar == 0xa) printf("\033[1A"); +} +} +float therm(unsigned short int t) +{ + float th,temp; + th = t; + th = 10000./((4095./th) -1.); + temp = -273. + 1./(0.00102522746225986 + 0.000239789531411299*log(th) + 1.53998393755544E-07*pow(log(th),3)); + return temp; +} + +int +main(int argc, char *argv[]) +{ + + char dll_date[32], dll_time[32]; + char waitnum; + int nofile; + char *parseptr; + pthread_t threads[NUM_THREADS]; + struct sched_param param; + pthread_attr_t tattr; + + int *taskids[NUM_THREADS]; + int ret, t, i; + float f; + + displayonce = 0; + displaycont = 1; + showhkp = 0; + + // define the custom priority for one of the threads + int newprio = -10; + // define the thread that will get the custom priority + int prioid = 0; + + param.sched_priority = newprio; + ret = pthread_attr_init(&tattr); + + // set the new scheduling param + ret = pthread_attr_setschedparam (&tattr, ¶m); + + printf("\033[2J \033[65;0H ---- FOXSI gse setup ----\n"); + if (FALSE == okFrontPanelDLL_LoadLib(NULL)) + { + printf("FrontPanel DLL could not be loaded.\n"); + return(-1); + } + okFrontPanelDLL_GetVersion(dll_date, dll_time); + printf(" FrontPanel DLL loaded.Built: %s %s\n", dll_date, dll_time); + + + while (argc > 1) + { + ++argv; + parseptr = *argv; + if(*parseptr == '-') + { + if(*(parseptr + 1) == 'n') nofile = 1; + } + argc--; + } + + // Initialize the FPGA with our configuration bitfile. + okCFrontPanel *devi = initializeFPGA(); + if (NULL == devi) + { + printf("FPGA could not be initialized.\n"); + return(-1); + } + + fout = 0; + printf("\033[65;0H "); + if( nofile == 0) + { + printf(" Opening "); + Startfile(); + } + + if (NULL != devi) + { + + ret = pthread_create(&threads[0], &tattr, readgse, (void *) taskids[0]); + pthread_mutex_init(&mymutex,NULL); + ret = pthread_create(&threads[0], NULL, charcommand, (void *) taskids[1]); + + } + for(;;) + { + if( newdisplay == 1) + { + pthread_mutex_lock( &mymutex); /* wait on readgse */ + bufptr = buffer; + for(i = 0; i < 4; i++) + { + frameno = *(bufptr+5); + subcom = frameno & 0x3; + switch(subcom) + { + case 0: + hkp[0] = *(bufptr+6); + hkp[1] = *(bufptr+10); + hkp[2] = *(bufptr+14); + hkp[3] = *(bufptr+18); + break; + case 1: + hkp[4] = *(bufptr+6); + hkp[5] = *(bufptr+10); + hkp[6] = *(bufptr+14); + hkp[7] = *(bufptr+18); + break; + case 2: + hkp[8] = *(bufptr+6); + hkp[9] = *(bufptr+10); + hkp[10] = *(bufptr+14); + hkp[11] = *(bufptr+18); + break; + case 3: + hkp[12] = *(bufptr+6); + hkp[13] = *(bufptr+10); + hkp[14] = *(bufptr+14); + hkp[15] = *(bufptr+18); + break; + } + bufptr += 256; + } + if((displayonce != 0) ||(displaycont != 0)) + { + displayonce = 0; + printframe(buffer); + if(showhkp != 0) + { + printf("\033[3B"); // down column + f = hkp[0]; + Tref = (( f -917.28)*0.30525) + 25. ; + f = hkp[1]; + V5V = 8.75*( f /4095.); + f = hkp[2]; + VM5V = 2.5 - 15.*( f /4095.); + f = hkp[3]; + V33V = 5.*( f/4095.); + f = hkp[4]; + V15V = 2.5*( f/4095.); + T1 = therm(hkp[5]); + T2 = therm(hkp[6]); + T3 = therm(hkp[7]); + T4 = therm(hkp[8]); + T5 = therm(hkp[9]); + T6 = therm(hkp[10]); + T7 = therm(hkp[11]); + T8 = therm(hkp[12]); + T9 = therm(hkp[13]); + T10 = therm(hkp[14]); + T11 = therm(hkp[15]); + printf("Tref = %6.1f, 5V mon = %6.2f, -5V mon = %6.2f, 3.3V mon = %6.2f \n",Tref,V5V,VM5V,V33V); + printf("1.5V mon = %6.2f,T1 = %6.1f, T2 = %6.1f, T3 = %6.1f \n",V15V,T1,T2,T3); + printf("T4 = %6.1f, T5 =%6.1f, T6 = %6.1f, T7 = %6.1f \n",T4,T5,T6,T7); + printf("T8 = %6.1f, T9 = %6.1f, T10 = %6.1f, T11 = %6.1f \r\033[6A",T8,T9,T10,T11); + } + newdisplay = 0; + fflush(stdout); + } + pthread_mutex_unlock(&mymutex); + } + + } + + return(0); +} diff --git a/data.cpp b/data.cpp index ef37bc9..4adae55 100755 --- a/data.cpp +++ b/data.cpp @@ -146,6 +146,9 @@ void data_initialize(void) gui->startReadingDataButton->activate(); gui->closeBut->activate(); gui->detector_choice->activate(); + gui->app->flush_image(); + gui->app->flush_histogram(); + gui->app->flush_timeseries(); gui->app->print_to_console("Done initializing.\n"); } } @@ -304,7 +307,8 @@ void* data_read_data(void *p) // read from the USB/Formatter, reads 4 frames at a time. len = dev->ReadFromBlockPipeOut(0xA0,1024,2048,(unsigned char *) buffer); // set the read status based on how len returned - if (len == 2048){ read_status = 1; printf("read okay\n");} + if (len == 2048){ read_status = 1; // printf("read okay\n");} + } } if (read_status == 1) { @@ -324,8 +328,8 @@ void* data_read_data(void *p) newdisplay = 1; } pthread_mutex_unlock(&mymutex); - } else {printf("failed to pass off data\n");} - + } else {// printf("failed to pass off data\n");} + } // Check to see if if only a fixed number of frames should be read // if so set the stop message if ((maxreads != 0) && (nreads >= maxreads)){ @@ -782,23 +786,26 @@ void data_update_display(unsigned short int *frame) for( int frame_number = 0; frame_number < 4; frame_number++) { + //printf("f628: %x\n", buffer[index++]); if (buffer[index++] == 0xf628) { - - //printf("checksum: %u\n", buffer[index+253]); - //printf("eb90: %x\n", buffer[index+254]); + read_status = 1; + printf("checksum: %u\n", buffer[index+253]); + printf("eb90: %x\n", buffer[index+254]); // check the checksum for( int word_number = 0; word_number < 254; word_number++ ){read_status ^= buffer[index+word_number];} + printf("read status: %u\n", read_status); + read_status = 1; if( read_status == 1 ){ nreads++; //printf("calc checksum: %u\n", checksum); printf("index = %u\n", index); - printf("time1(MSB): %u\n", buffer[index++]); - printf("time2: %u\n", buffer[index++]); - printf("tim3(LSB): %u\n", buffer[index++]); - printf("frame counter 1: %u\n", buffer[index++]); - printf("frame counter 2: %u\n", buffer[index++]); + printf("time1(MSB): %x\n", buffer[index++]); + printf("time2: %x\n", buffer[index++]); + printf("tim3(LSB): %x\n", buffer[index++]); + printf("frame counter 1: %x\n", buffer[index++]); + printf("frame counter 2: %x\n", buffer[index++]); frameNumber = buffer[index]; // Housekeeping 0 @@ -847,7 +854,7 @@ void data_update_display(unsigned short int *frame) } printf("FormatterStatus: %u\n", buffer[index++]); - index++ // printf("0: %u\n", buffer[index++]); + printf("0: %u\n", buffer[index++]); index++; high_voltage_status = buffer[index] & 0xF; @@ -873,9 +880,9 @@ void data_update_display(unsigned short int *frame) break; } - index++ // printf("Status 0: %u\n", buffer[index++]); - index++ // printf("Status 1: %u\n", buffer[index++]); - index++ //printf("Status 2: %u\n", buffer[index++]); + index++; // printf("Status 0: %u\n", buffer[index++]); + index++; // printf("Status 1: %u\n", buffer[index++]); + index++; //printf("Status 2: %u\n", buffer[index++]); // Housekeeping 3 switch (frame_number) { @@ -901,7 +908,7 @@ void data_update_display(unsigned short int *frame) printf("Status 4: %u\n", buffer[index++]); printf("Status 5: %u\n", buffer[index++]); printf("Status 6: %u\n", buffer[index++]); - printf("index = %u\n", index); + //printf("index = %u\n", index); for(int detector_number = 0; detector_number < 7; detector_number++){ printf("Detector %u time: %u\n", detector_number, buffer[index++]); @@ -921,8 +928,9 @@ void data_update_display(unsigned short int *frame) strip_data = buffer[index] & 0x3F; strip_number = (buffer[index] >> 10) & 0x3FFF; - if (strip_data >= low_threshold){ + if ((strip_data >= low_threshold) && (strip_data < 1023)){ num_hits++; + printf("hit! strip value %u\n", strip_data); if (asic_number < 2) { // n side asic @@ -930,7 +938,7 @@ void data_update_display(unsigned short int *frame) } if (asic_number > 1) { // p side asic - xstrips[strip_number + (asic_number -2) * 64] = 1; + xstrips[strip_number + (asic_number - 2) * 64] = 1; if (strip_data > 0){ HistogramFunction[strip_data]++; } } @@ -977,7 +985,7 @@ void data_update_display(unsigned short int *frame) //temperature_values[0] = convert_temperature( for(int num = 1; num < 12; num++) - {temperature_values[num] = temperature_convert_ysi44031(temperature_monitor[num]);} + {temperature_values[num] = temperature_convert_ysi44031(temperature_monitors[num]);} Fl::lock(); gui->tempOutput->value(temperature_values[0]); diff --git a/documentation/FOXSITelemFrameD.xls b/documentation/FOXSITelemFrameD.xls index 543c0eb..8b21774 100644 Binary files a/documentation/FOXSITelemFrameD.xls and b/documentation/FOXSITelemFrameD.xls differ diff --git a/telemetry.cpp b/telemetry.cpp index 777bb18..ca4b619 100755 --- a/telemetry.cpp +++ b/telemetry.cpp @@ -35,9 +35,9 @@ float temperature_convert_ysi44031(int value) frac = value/4095.0; voltage = 2.5*frac; resistance = 10000.0 * frac/ ( 1.0 - frac ); - printf("%f\n",resistance); + //printf("%f\n",resistance); temperature = 1 / (c1 + c2 * log(resistance) + c3 * (pow(log(resistance),3))) - 273.15 - 9.73; - printf("%f\n", temperature); + //printf("%f\n", temperature); return temperature; }