• RE: Best Way for Live Data Acquisition from Tektronix TBS1102C Oscilloscope in Python

    Hi Afonso, 

    I'm now using a DPO 7354 oscilloscope with the curvestream function as opposed to the 1000 series. Thus, I'm inquiring if the FFT() function on the DPO7354 is still slower than a python script would be. I ask this because we are building calibration functionality where the max() of the FFT is taken to determine where the best signal is along shifting frequencies and a moving mirror if that makes sense. Thus, timing and speed are important.

    If the 7000 series can handle this fast enough, I have posted my current code in another thread as a response to your other answer to my previous question.

    Thanks,
    "Big" Jim
  • RE: How to receive Math() [SpectralMag/FFT] in Python via PYVISA

    Hi Afonso,

    When I pull in the SpectralMag data as floating point values, I get 100 values, even though my record length is 1k. 

    Here's the code: 

    scope.write('MATH1:DEFINE "AVG(CH1)"')
        scope.write('MATH2:DEFINE "SpectralMag(Math1)"')
        scope.write('MATH2:SPECTral:SPAN 100E6')
        scope.write('MATH2:SPECTral:CENTER 100E6')
        print(scope.query('MATH1:DEFINE?'))
        #scope.write('autoset EXECUTE') # autoset
        t3 = time.perf_counter()
        r = scope.query('*opc?') # sync
        t4 = time.perf_counter()
        print('autoset time: {} s'.format(t4 - t3))
       # io config
        scope.write('header 0')
        scope.write('data:encdg SRIBINARY')
        scope.write('data:source MATH2') # channel
        scope.write('data:start 1') # first sample
        record = int(scope.query('horizontal:recordlength?'))
        scope.write('data:stop {}'.format(record)) # last sample
        scope.write('wfmoutpre:byt_n 1') # 1 byte per sample
        # acq config
        scope.write('acquire:state 0') # stop
        scope.write('acquire:stopafter SEQUENCE') # single
        scope.write('acquire:state 1') # run
        t5 = time.perf_counter()
        r = scope.query('*opc?') # sync
        t6 = time.perf_counter()
        print('acquire time: {} s'.format(t6 - t5))
        print(scope.query('BUSY?'))
        scope.write('acquire:state ON') # run
        print(scope.query('BUSY?'))
        t5 = time.perf_counter()
        #r = scope.query('*opc?') # sync
        t6 = time.perf_counter()
        print('acquire time: {} s'.format(t6 - t5))
        # data query
        t7 = time.perf_counter()
        bin_wave = scope.query_binary_values('curve?', datatype='f', container=np.array)
        print("binwave:")
        print(bin_wave)
        t8 = time.perf_counter()
        print('transfer time: {} s'.format(t8 - t7))
        # retrieve scaling factors
        tscale = float(scope.query('wfmoutpre:xincr?'))
        print(tscale)
        tstart = float(scope.query('wfmoutpre:xzero?'))
        vscale = float(scope.query('wfmoutpre:ymult?')) # volts / level
        voff = float(scope.query('wfmoutpre:yzero?')) # reference voltage
        vpos = float(scope.query('wfmoutpre:yoff?')) # reference position (level)
        # error checking
        r = int(scope.query('*esr?'))
        print('event status register: 0b{:08b}'.format(r))
        r = scope.query('allev?').strip()
        print('all event messages: {}'.format(r))
        scope.close()
        rm.close()
    def plotMath():
        global scaled_wave
        # create scaled vectors
        # horizontal (time)
        total_time = tscale * record
        tstop = tstart + total_time
        scaled_time = np.linspace(0, tstop, num=record, is_big_endian=False ,endpoint=False)
        # vertical (voltage)
        unscaled_wave = np.array(bin_wave, dtype='float') # data type conversion

  • RE: Best Way for Live Data Acquisition from Tektronix TBS1102C Oscilloscope in Python

    Afonso,

    You are great. Thank you for the help & support. I will take the raw data and FFT it myself. I was planning on running the scope and FFT on different threads when I started this project but thought the FFT on the scope would be faster - thanks for the correction. 

    Investigating the sample rate now. 

    I'll update you here later today. Let me do some work and see what I can come up with.

    Thanks greatly,
    "Big" Jim
  • Best Way for Live Data Acquisition from Tektronix TBS1102C Oscilloscope in Python

    Hello,

    Looking to get live fourier transform data for use in controlling other components in Python based on this data. 

    I'm wondering if there's a live acquisition mode instead of quickly sending commands to get data. I'm also wondering if there's any code examples to get continuous data instead of having to run a loop with similar code:

    scope.write("*CLS")
    scope.write('header 0')
    scope.write('WFMO:ENC BIN')
    scope.write("*ESR?")
    print(scope.query("EVM?"))
    scope.write('SELect:FFT ON')
    print(scope.query("FFT?"))
    scope.write('ACQuire:MODe SAMple')
    scope.write('DATA:WIDTH 1')
    scope.write('ACQuire:STATE RUN')
    print(scope.query('ACQuire:STOPA?'))
    print(scope.query('ACQuire:STATE?'))
    scope.write('DATA:SOURCE FFT')
    scope.write('DATA:START 1')
    scope.write('DATA:STOP 2000')
    print(scope.query('WFMO:BYT_N?;NR_P?;YOF?;YMU?;YZE?;XIN?;XZE?'))
    values = np.array(scope.query_binary_values('CURV?', datatype='b'))

    I would really appreciate the help from anyone familiar with these sorts of applications. Thank you greatly
  • How is this forum so bad?

    I can't search anything, I can't see my old posts, I can't find a solution that was posted to one of my questions. 

    The old forum system was much better. Why would you ever downgrade in this manner?
  • How to receive Math() [SpectralMag/FFT] in Python via PYVISA

    Hi guys,

    Writing software to control a spectrometer we are building and I'm having trouble getting math command data in from the oscilloscope (DPO7354). 

    I have written the math functions (which correct display in the math function group on the oscilloscope thus I know they are being written) as:
    scope.write('MATH1:define "avg(CH1)"')
    scope.write('MATH2:define "spectralMag(MATH1)"')

    then, I set the source channel: 
    scope.write('data:source MATH2')

    but I get a timeout error that doesn't occur when I just read from CH1.

    Here's (most) code:

    scope.write('MATH1:define "avg(CH1)"')
    scope.write('MATH2:define "spectralMag(MATH1)"')
    #io config
    scope.write('header 0')
    scope.write('data:encdg SRIBINARY')
    scope.write('data:source CH1') # channel
    scope.write('data:start 1') # first sample
    scope.write('HORIZONTAL:MODE:SCALE 200e-9')
    print(scope.query('horizontal:recordlength?'))
    record = int(scope.query('horizontal:recordlength?'))
    print(record)
    scope.write('data:stop {}'.format(record)) # last sample
    scope.write('wfmoutpre:byt_n 1') # 1 byte per sample
    # acq config
    scope.write('acquire:state 0') # stop
    scope.write('acquire:stopafter SEQUENCE') # single
    scope.write('acquire:state 1') # run
    t5 = time.perf_counter()
    r = scope.query('*opc?') # sync
    t6 = time.perf_counter()
    print('acquire time: {} s'.format(t6 - t5))

    I get a timeout error when I try to write the .bin data:
    #bin_wave = scope.query_binary_values('curve?', datatype='b', container=np.array)
    bin_wave = scope.write('CURVE?')

    The commented out line works for CH1, but nothing I try works for MATH2.