# Reading digital wafevorms via VXI11 from the LeCroy wavesurfer 510/MS-500

I automating a test with an osciloscope via VXI11 with python's vxi11 package. I am using the remote control manual given by LeCroy.

I am trying now to extract the raw Waveformdata according to page 254 with the waveform command like this:

import vxi11
instr=vxi11.Instrument(instrIP)


which works for analoge channels, but I want to get the recording of the MS-500 digital channels, which I already recorded.

I tried already C9:WF? (causes fatal error 1597), Digital2:WF? (error log: illegal header path for command) and don't know what else to try, if anybody has an idea :)

I had some e-mails with a LeCroy FAE. The result was, for reading digital waveforms of the MS-500/250 you need to send visual basic commands to query the X-Stream Objects from the scope see docs at section for, or use the XStream Browser, which comes pre-instaled on the scope to see the object hierarchy of the object on the scope.

To generally access the Digital results use

VBS? 'return=app.LogicAnalyzer.Digital1.Out.Result.XXX'

where XXX is the result of the results object. The actual waveform is within DataArray, which is a 2D-Array with x -> Samples and y -> digital Line, with two further arguments for offsets of samples and sparseing.

#VBS? 'return=app.LogicAnalyzer.Digital1.Out.Result.DataArray(nr_samples, nr_lines, offset_samples, frameOffset, lineOffset)'
VBS? 'return=app.LogicAnalyzer.Digital1.Out.Result.DataArray(1,1,0,0)(0,0)'


The catch is, that you only can transmit strings up to 32768 length, which is a bummer for a million+ samples. So writing a VBS script to go with your scope command is kind of inevitable.

I use python and the vxi11 lib for communication:

import vxi11

def getDigitalWaveForm(setup=2, line=0):
cmd_line = ":".join(["VBS? 't=\"\"",
"num_samples = app.LogicAnalyzer.Digital%d.Out.Result.Samples" % setup,
"sample=0",
"last_sample=255",
"res = app.LogicAnalyzer.Digital%d.Out.Result.DataArray(-1,1,0,%d)" % (setup, line),
"for j = 0 To 20000000",
"sample = res(j,0)",
"If ( (last_sample) <> (sample) ) Then " "last_sample=sample:t = t & sample & \"@\" & j & \",\" " "End If",
"Next",
"return=t"
])
print(cmd_line)
return samples

instr=vxi11.Instrument("169.254.70.213")
instr.timeout = 30 # reading a channel took ~9.1 seconds, but to be safe from timouts for sure
l1 = getDigitalWaveForm(line=1)
print("l1", l1)
>>> VBS 0@0,1@3870004,0@15539981,
l2 = getDigitalWaveForm(line=2)
print("l2", l2)
>>> VBS 0@0,1@14390413,0@14390416,1@14392593,0@14392596,1@14394773,0@14394776,1@14396953,0@14396956,1@14399133,0@14399136,
`

Since transmitting all the samples is to time-data consuming I loop over all the samples of a given channel and saved only the logic edges and added them with the sample index to the return string. It's rather dumb and crashes for to fast singnals (remind the 32k limit of the return string), but enough for my purposes ;)

If anybody has some idea for imporvments, let me know. WaveStudio transmits the data somehow binary, and is a little faster, but I didnt find any docs for the API...