read out a binary waveform from a LeCroy oscilloscope using the SOCKIT xop
string command // command must not exceed 255 characters!!
variable a=strlen(command)
string LecroyStr=num2char(129)+num2char(1)+num2char(1)+num2char(0)
LecroyStr+=num2char(0)+num2char(0)+num2char(0)
LecroyStr+=num2char(a)
LecroyStr+=command
return LecroyStr
End
function LeCroyReadOutBinWaveForm(bufferwave,entry)
wave/t bufferwave
variable entry
variable pos=4
variable blockLen
variable i
for(i=0;i<4;i+=1)
blockLen+=(char2num((bufferwave[entry][0])[pos])<0 ? char2num((bufferwave[entry][0])[pos])+256 : char2num((bufferwave[entry][0])[pos]))*(256^(3-i))
pos+=1
endfor
string headerStr=(bufferwave[entry][0])[pos,pos+blockLen-1]; pos+=blockLen
headerStr=replacestring(" ",headerStr,""); headerStr=replacestring("\"",headerStr,"")
print headerStr
blockLen=0; pos+=4
for(i=0;i<4;i+=1)
blockLen+=(char2num((bufferwave[entry][0])[pos])<0 ? char2num((bufferwave[entry][0])[pos])+256 : char2num((bufferwave[entry][0])[pos]))*(256^(3-i))
pos+=1
endfor
string blockFormatStr=(bufferwave[entry][0])[pos,pos+blockLen-1]; pos+=blockLen
print blockFormatStr
blockLen=0; pos+=4
for(i=0;i<4;i+=1)
blockLen+=(char2num((bufferwave[entry][0])[pos])<0 ? char2num((bufferwave[entry][0])[pos])+256 : char2num((bufferwave[entry][0])[pos]))*(256^(3-i))
pos+=1
endfor
print blockLen // number of data bytes
// make/n=(blockLen/2)/o/w LeCroyWave // because there are two byte words...
// string S_tmp=uniquename("tmp",1,0); make/n=(blockLen)/o/b/u $S_tmp; wave W_tmp=$S_tmp
// W_tmp=char2num((bufferwave[entry][0])[pos+p]); pos+=blockLen
// LeCroyWave=W_tmp[2*p]*256+W_tmp[2*p+1]
// killwaves W_tmp
// redimension/s LeCroyWave
make/n=(blocklen)/o/b/u LeCroyWave
LeCroyWave=char2num((bufferwave[entry][0])[pos+p]); pos+=blockLen
redimension/w/e=2/n=(blocklen/2) LeCroyWave // one data point is a two-byte word
redimension/s LeCroyWave
LeCroyWave=LeCroyWave*numberbykey("VERTICAL_GAIN",headerStr)-numberbykey("VERTICAL_OFFSET",headerStr)
setscale/p x,numberbykey("HORIZ_OFFSET",headerStr),numberbykey("HORIZ_INTERVAL",headerStr),"s",LeCroyWave
setscale d,0,0,"V",LeCroyWave
// display LeCroyWave
end
And on the command line (replace "172.25.1.2" with the IP address of your scope and 'F1' with the trace or function you want to read out):
•variable socketID; make/n=0/t bufferwave
•SOCKITopenConnection/q socketID,"172.25.1.2",1861,bufferwave
•SOCKITregisterProcessor(socketID,"")
•msg=makemsgstr("CHDR OFF;CORD HI;CFMT DEF9,WORD,BIN")
•SOCKITsendmsg socketID, msg
•msg=makemsgstr("WFSU SP,0,NP,5000,FP,0,SN,0")
•SOCKITsendmsg socketID, msg
•SOCKITregisterProcessor(socketID,"LeCroyReadOutBinWaveForm")
•msg=makemsgstr("F1:INSPECT? 'VERTICAL_GAIN';F1:INSPECT? 'VERTICAL_OFFSET';F1:INSPECT? 'HORIZ_INTERVAL';F1:INSPECT? 'HORIZ_OFFSET';F1:WF? DAT1")
•sockitsendnrecv socketID, msg
VERTICAL_GAIN:8.5753e-005;VERTICAL_OFFSET:8.5753e-005;HORIZ_INTERVAL:2.0000e-010;HORIZ_OFFSET:-2.00000000e-009;DAT1,
#9000000202
202
•SOCKITcloseConnection(socketID)
A wave ("LeCroyWave") is created that contains the waveform data.
With this simple code you can only read out a waveform that is transferred at once, because otherwise the data is written in consecutive rows of the bufferwave which cannot be handled properly by the processorfunction.
N.B. It's a snap shot just to illustrate that it is in principle possible.
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More