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