Data AQuisition Programming
List of programmable equipment:
- Multimeter Keithley Sourcemeter 2400
- Monochromator CVI Digikrom DK240
- Lock-in Amplifier Stanford Research SR830
- Temperature controller Cryocon CC-32 (docs)
- Temperature controller Brainchild C-21
- Temperature controller Eurotherm 3200
- Film evaporation thickness monitor Inficon SQM-160
- Arbitrary function generator Tektronix AFG3100
- Digital oscilloscope Lecroy WavePro 7
- Solar simulator PET SS50AAA
- Programmable high voltage supply Caen N1470
- Thorlabs power meter PM120
- Spectrometer Tristan USB High Resolution minispectrometer
- Ellipsometer with HUBER stepper motors (docs).
- Thorlabs power and energy meter PM320 (webpage)
- Red pitaya STEM lab 125-14 (webpage)
- Ophir laser power meter EA-1 (webpage)
- Digital oscilloscope Tektronix DSA91304A
Please contact the owner for programming documentation. We provide an open-source software development kit – DAQ (contact us to get source). This development kit offers complete set of classes, which can be used to establish connection to equipment using different protocols (RS232, modbus, gpib, vxi,…). Use of these clasess is as simple as this example code (example.cc), which reads the temperature from the temperature controller:
#include "TLSerial.h" int main(){ int debug=1;//povecaj ce rabis debug TLconnect* port=0; port=(TLconnect*)new TLSerial(1024); //port=TLvxi::OpenPort(porta,debug); //port=TLNet::OpenPort(porta,debug); //port=TLgpib::OpenPort(porta,debug); //port=TLSerial::OpenPort(porta,debug,this); port->fdebug=debug; if(port->Init("/dev/ttyS0")<1) { port->Message(0,"Sorry, but port could not be opened."); return 0; } port->fstop="\n";//set stop char port->Send("*IDN?"); char answer[1024]; port->Receive(answer,1024); std::cout<<"Received "<<answer<<std::endl; return 0; }
Compilation and linking is performed by issuing the following command:
g++ example.cc TLSerial.cpp -o example
And voila!
Download the code here: tutorial.tar
Alternative possibility to control above devices is by using the
following code. Remember that this code requires ROOT toolkit.
#include <iostream> using namespace std; #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> #include <unistd.h> #include <cstdio> #include <cstring> #include <time.h> #include <TROOT.h> #include <TApplication.h> #include <TCanvas.h> #include <TGraph.h> #include <TH1F.h> #include <TSystem.h> bool serwrite(int fd, const char* ukaz, const char termination = '\n') { int nwrite=strlen(ukaz)+1; char buf[1024]; strcpy(buf,ukaz); strncat(buf,&termination,1); int nc = write(fd, buf ,nwrite ); if (nc != nwrite ) return false; return true; } bool serread(int fd, char* buf) { char c; int i = 0; while ( true ) { fd_set readfds; FD_ZERO(&readfds); FD_SET(fd,&readfds); struct timeval timeout; timeout.tv_sec = 5; timeout.tv_usec = 0; select(fd+1,&readfds,0,0,&timeout); int nc = read(fd,&c,1); if ( nc < 1) continue; buf[i] = c; i++; if ( c == '\n' ) { break; } } buf[i-2]=0; return true; } int main(int argc, char ** argv) { //cout << "stevilo argumentov" << argc << endl; //cout << argv[1] << endl ; if (argc < 2 ) { cout <<"Usage: "<<argv[0]<<" <serialport>" << endl; return -1; } //int fd = open ("/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NONBLOCK ); char* sport=argv[1]; int fd = open (sport, O_RDWR|O_NOCTTY|O_NONBLOCK ); if ( fd < 0 ) { cout << "Serijska vrata niso bila uspesno odprta" << endl; return -1; } termios term; term.c_iflag = 0; term.c_oflag = 0; // nastavitev lastnosti serijskih vrat term.c_cflag = B9600|CS8|CRTSCTS|CREAD; term.c_lflag = 0; int rc = tcsetattr ( fd, TCSANOW, &term); if ( rc < 0 ) { cout << "Napaka pri nastavitvi serijskih vrat" << endl; return -1; } char buf[1023]; // while (true) { int nmeritev = 10 ; double x[nmeritev]; double y[nmeritev]; TApplication app("App", &argc, argv); TCanvas canvas; TGraph g(nmeritev); long t0=time(0); for ( int i=0 ; i<nmeritev ; i++) { g.SetPoint(i,i,0); } for ( int i=0 ; i<nmeritev ; i++) { bool rcukaz = serwrite(fd,":POWER?"); usleep(1000000); // spimo 1 sec serread(fd,buf); // cout << buf << endl; double power; sscanf(buf,"%lf",&power); cout << time(0) << " " << power << endl; x[i] = time(0) - t0 ; y[i] = power; g.SetPoint(i,x[i],y[i]); g.Draw("ALP"); canvas.Modified(); canvas.Update(); } //TGraph g(nmeritev,x,y); app.Run(); }