2

I am trying to capture the data from a Lecroy 12 bit oscilloscope using Matlab.

I create the visa object "scope", set the format length to "word" (16 bit) and then use "fread" to get the waveform data as 16 bit signed integers:

fwrite(scope,'comm_format Def9,word,bin'); % The only relevant thing here is the "word" setting 

fwrite(scope,'C1:Wf?'); % This gets the waveform from channel 1 on the scope

[wf]=fread(scope,SampleSize,'int16');

The problem is that the data that is captured has 8-bit noise on it. I attached a picture that shows a zoomed in portion of the waveform. You can see there is a signal that would be the full 12 bit resolution of the scope, but there seem to be glitches occasionally that are digitized to 8 bits. These glitches do not appear on the scope, only on the captured data.

Here is my sample data:

Sample Data

Does anyone know what causes this and how I can correct it?

Addison
  • 7,322
  • 2
  • 39
  • 55
nbrewer
  • 21
  • 2

3 Answers3

1

Your oscilloscope data is 12 bits, but you are using 'word' which is 16 bits. Using 'bit12' flag might solve your problem. Also remember to use 'bit12' in fread() function.

abyesilyurt
  • 399
  • 3
  • 13
0

The screenshot looks a bit like the scope samples with 8 bit and the 12 bit are achieved by averaging multiple samples. This is a common practice of improving resolution in sigma delta converters. I'm trying to make an ASCII drawing:

signal ---->(+)----->8 bit ADC --> digital averaging 256 samples --> 12 bit
         |
       noise (+-1LSB)

Maybe you have to implement this in software to get 12 bit out of the raw data. (The 4 LSB information of the 12 bit is in the statistical distribution of 256 8-bit-samples) If you look at the screen you already see processed data - not the raw data.

m4n0
  • 29,823
  • 27
  • 76
  • 89
0

I would:

Consult the scope manual and see what processing the scope is applying to the visa-capture-data and what processing is applied to the data shown on the scope's display. If they are different, that may be the problem. Consult any documentation from the scope manufacturer on the interface, comparing this to matlab's/NI's documentation for their interface looking for any differences in expected formatting.

Try to view the raw data, bytes on the wire, to see if there is maybe a formatting issue. Compare to the formatting visa is expecting.

Manipulate the dataset to look for patterns. Use something like pyvisa that lets you quickly try a lot of different parameters.

Run different signals and check for patterns. In particular look for any relationships between the number of 8-bit samples and frequency, amplitude. Try both ac and dc coupling. Its also possible there is interference from the digital communications, you could try isolating circuits with an isolation transformer, or an isolated digital link to the scope (although if using ethernet, it may already be isolated via magnetics).

I would provide more details when looking for help. Some of the things I would provide would be the oscilloscope used, the things I have tried to solve the problem, the axis labels on the capture plot, a dump of the captured samples and the type of connection I am using to the instrument (lan, 485 etc).

Finally, if I resolved the issue, tried the provided solutions and didn't have any luck with them or had given up all hope and ran off to join the circus, I would be sure to update my question on SO to reflect that.