//------------------------------------------------------------------------------------------------------- // // This program drives a bitscope USB-scope to capture DCS signals and return their voltage // capture.c program // // Requirements: // Trigger on the rising edge of CHA // Save 12000 Samples from CHA at the fastest rate possible // Write those 12000 values to a file when done // //------------------------------------------------------------------------------------------------------- //Includes #include #include #include #include #include #include #include #include #include #include #include #include //Constants #define MY_DEVICES 1 #define MY_PROBE_FILE "/home/bitscope.prb" // default probe file if unspecified #define MY_DEVICE 0 // device number #define CHANNELA 0 #define CHANNELB 1 #define MY_MODE BL_MODE_FAST #define MY_RATE 20000000 // capture sample rate... this is 20MS/s #define MY_SIZE 12000 // number of samples to capture #define GNUPLOT "gnuplot" //Defines the baud rate of the USB Link to the LCD Panel #define BAUDRATE B57600 //Define the buffer size for the FTL interface #define BUF_SIZE 0x100000 // 1 Megabyte Data Buffer //this function is for printing to GNU plot void gnuprint(FILE *gp, double x[], int N) { int i; fprintf(gp, "plot '-' with lines \n"); for (i=0;i voltageH){ voltageH = results[ctr];} } voltage=voltageH-voltageL; //--------------------------------------------------------------- // RESULT PLOTING FOR GNUPLOT //--------------------------------------------------------------- //set the gnu plot bounds results[11998] = -12; results[11999] = 12; printf("DCS detected: %d values captured pk-pk-voltage %5.3f: power %lf \n",actual_read, voltage, power); gnuprint(gp,results,12000); //--------------------------------------------------------------- // RESULT PLOTING FOR LCD //--------------------------------------------------------------- //convert voltage to a string if (voltage <10){ sprintf(buf_stream, "%5.3lf",voltage); } else sprintf(buf_stream, "%5.2lf",voltage); } printf("LCD: %s\n",buf_stream); sleep(2); //Wait before the next DCS packet comes //Configure Stream char LCD[5]; LCD[0] = buf_stream[0]; LCD[1] = buf_stream[1]; LCD[2] = buf_stream[2]; LCD[3] = buf_stream[3]; LCD[4] = buf_stream[4]; n = write(USB,LCD,5); if (n<0){ perror("send command failed -"); } } //Shut down the bitscope to release system resources exit: delay(500); BL_Close(); printf("State: BL Close complete\n"); close(USB); return(0); }