Posted Thu, 17 Nov 2022 06:14:24 GMT by Long, David
Hi,

I'd like to record and save several waveforms in quick succession, e.g. up to five waveforms per second. I would like to analyse the waveforms later on a computer. How can I do this? 

I currently have a Tektronix DPO 2024b. I have been manually saving single waveforms to a USB drive. This is too slow for what I want to do.

Are there some software extensions which can do what I want if I connect my computer to the oscilloscope? Or a particular model of oscilloscope that is better suited to this than the DPO 2024b model I currently have? Would I need to write any code for this myself (I have zero experience in oscilloscope programming).  

I have found "TekScope Utility" by searching through this forum on similar topics. I haven't got this working yet, but am playing around with it. 
Posted Thu, 17 Nov 2022 17:32:26 GMT by Teles, Afonso
Hi David,

Indeed TekScope Utility is a great community made tool that can get and save waveform data from your instrument.
It appears you want to get the data in quick succession under some event/condition. For that you should go to the "Data Logger" tab in TekScope Utility.
There you can configure it to save analog waveform data on triggering or on a timer.

If TekScope Utility doesn't provide the functionality you need, then you can try the programmer's manual for the DPO2000, together with ready made remote control examples.
Posted Fri, 25 Nov 2022 04:03:01 GMT by Long, David
Thanks Afonso.

TekScope Utility would be perfect for me, but in some tests I did it was too slow at saving the waveforms. It looks like the author was thinking about adding in the ability to save binary files to speed the saving process up but this hasn't been done yet. It also looks like the scope I have (DPO 2024 b) isn't supported by the official TekScope program, which has the ability to export binary files. 

So these last few days I've been looking at writing my own program with Python. Are you able to help with this, or should I start a new thread? I would ask on forum.tek.com (where the remote control examples you linked to are located) but they are longer accepting new users and will close down at the end of the year. New questions below:

My aim is to write a Python program that will save on trigger events, transfer the waveform data to my laptop, then get itself ready for a new trigger event and repeat until my tests are finished. So far I am able to communicate with the scope and plot some data from it, but I can't get the waveform files to save on my laptop. Here's my program:
 
import pyvisa
import time
import numpy as np
import matplotlib.pyplot as plt
from struct import unpack
#%%
rm = pyvisa.ResourceManager()
#print(rm.list_resources())

#Connect to the instrument
scope = rm.open_resource('USB0::0x0699::0x03A3::C040496::INSTR')
scope.timeout = 5000 #give it 5 seconds to respond

#Configure how files are saved
scope.write("SAVE:WAVEFORM:FILEFORMAT SPREADSHEET") # spreadsheet = .csv, internal=.isf
scope.write("SAVE:WAVEFORM:SPREADSHEET:RESOLUTION FULL")

#Create directory where files will be saved
scope.write('FILESYSTEM:CWD \"C:/test_folder\"')
#scope.write('FILESYSTEM:MKDir \"C:/New"')

# follow steps on pg. 2-53 of programmers manual. Try to get a waveform to save here. 
scope.write('DATA:SOURCE CH1')
scope.write('DATA:ENCDG FASTEST') # not sure which format is appropriate here
scope.write('WFMOUTPRE:BYT_NR 1')
scope.write('DATA:START 1')
scope.write('DATA:STOP 125000')
preamble = scope.query('WFMOUTPRE?')
scope.write('CURVE?')
voltage = scope.read_raw()
voltage = np.asarray(list(voltage)) # needs to be scaled according to preamble
scope.write('SAVE:WAVEFORM ALL, \"C:/test_folder/test1\"')

# rest of the program now follows the example https://forum.tek.com/viewtopic.php?t=137002. 
# I've had this section commented out and been focused on the above section trying to get a single waveform to save.
#Start single sequence acquisition
scope.write("ACQ:STOPA SEQ")
loop = 0
while True:
    #increment the loop counter
    loop = loop + 1

    print ('On Loop %s' %loop)
    #Arm trigger, then loop until scope has triggered
    scope.write("ACQ:STATE ON")
    while '1' in scope.query("ACQ:STATE?"):
        time.sleep(0.001)
    #save all waveforms, then wait for the waveforms to be written
    scope.write("SAVE:WAVEFORM ALL, \"C:/New/All_%s\"" %loop)
    while '1' in scope.query("BUSY?"):
        time.sleep(0.001)
This code is largely combination of looking at the programming manual and a similar example from these forums.

I cannot get the waveform to save to my laptop. I can physically see a message flash up on the oscilloscope saying "Saving to C:/test_folder/test1" but no file appears there. I've tried manually creating a folder C:/test_folder and running, and using MKDIR and deleting parts of the filepath names (e.g. C:/test_folder, C:/test_folder/test1, C:/ ) .  I noticed that if I have the save step after voltage = np.asarray(list(voltage)), the program executes with no errors but doesn't save. Whereas if I put the save step immediately after scope.write('CURVE?') I get a timeout error message. I'm not sure what I'm missing.

The while loop sections seems to be working fine, only it isn't saving the waveform data. 

For reference, the preamble is 

1;8;BIN;RI;MSB;"Ch1, DC coupling, 2.000V/div, 200.0us/div, 125000 points, Sample mode";125000;Y;"s";16.0000E-9;-329.8560E-6;0;"V";80.0000E-3;-57.0000;0.0E+0;SINGULAR_YT;125000;200000000


 
 
Posted Mon, 28 Nov 2022 18:27:05 GMT by Teles, Afonso
Hi David,

The SAVE commands are generally used for saving to a mounted drive.
It appears what you want is to transfer the waveform over the connection.

To do this, you should use the following sequence:
scope.write('CURVE?')
data = scope.read_raw()
"CURVE?" outputs the waveform data and the following line reads that into an array you can then process and/or save as you wish.
Posted Fri, 01 Mar 2024 00:22:48 GMT by Wyban, David
Hi David.  I don't believe that the DPO2000 series is fast enough to produce waveforms out the remote interface (or even to a local USB drive) at 5 waveforms per second.  This scope will likely produce somewhere between 1-3 per second.  The reason for this has nothing to do with binary versus .csv saving format, but rather that the scope isn't quick enough to perform single sequence acquisitions and then spit out the data via CURVE? query that fast.  You might be able to achieve these rates on the new 2 Series MSO scopes (5/6 Series can definitely do these rates), but the good ol' DPO just doesn't quite have the compute power for it.

You must be signed in to post in this forum.