0

I have two Tektronix oscilloscopes:

scope 1: MDO34

scope 2: MDO4104C

I am running this code to get data from them:

def acquire_waveform(self, channel: str, recordlength: int=1000):
    """Get waveform data from channel

    Args:
        channel (str): Channel you want to get data from, default: CH1

    Return: list of waveform data in format (Time,Volts)
    """

    # set up
    self.write('ACQUIRE:STATE OFF')
    self.write(f'SELECT:{channel} ON')
    self.write(f'HORIZONTAL:RECORDLENGTH {recordlength}')
    self.write('ACQ:STOPAFTER RUNSTOP')

    # acquire waveform data
    self.write('ACQUIRE:STATE ON')
    self.write('DATA:SOURCE ' + channel)
    self.write('DATA WIDTH 1')
    self.write('DATA:ENC RPB')
    ymult = float(self.visa.query('WFMPRE:YMULT?'))
    yzero = float(self.visa.query('WFMPRE:YZERO?'))
    yoff = float(self.visa.query('WFMPRE:YOFF?'))
    xincr = float(self.visa.query('WFMPRE:XINCR?'))
    xdelay = float(self.visa.query('HORizontal:POSition?'))
    self.write('CURVE?')
    data = self.visa.read_raw()
    headerlen = 2 + int(data[1])
    header = data[:headerlen]
    ADC_wave = data[headerlen:-1]
    ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave))
    Volts = (ADC_wave - yoff) * ymult  + yzero
    Time = np.arange(0, (xincr * len(Volts)), xincr)
    return Time, Volts

When I do this for scope 1, I get the expected data. On scope 2, I get a constant value of about -2.52 V. Both scopes are displaying the data properly and are set up/triggering in the same way.

Ive tried using the MEAS:IMMED function and it seems to be able to measure things on the scope, but waveform data isn't being output how I expect it.

I am trying to acquire data from CH2.

This is the setup I'm using:

# HORIZONTAL
oscilloscope.write([
    'HORizontal:RECOrdlength 1000000',
    'HORIZONTAL:DELAY:MODE OFF',
    'HORIZONTAL:POSITION 50',
], 'Set scope horizonal record length, delay, and position')

# Scope CH1
oscilloscope.write([
    'CH1:BANdwidth FULl',
    'CH1:COUPLING DC',
    'CH1:TERMINATION MEG',
    'CH1:SCALE 0.5',
    'CH1:OFFSET 0.0',
    'CH1:POSITION 0',
    'SELECT:CH1 ON',
], 'Setup scope CH1')


# CH2
oscilloscope.write([
    'CH2:BANdwidthFULl',
    'CH2:COUPLING DC',
    'CH2:TERMINATION MEG',
    'CH2:SCALE 0.5',
    'CH2:OFFSET 0.0',
    'CH2:POSITION 0',
    'SELECT:CH2 ON',
], 'Setup scope CH2')


# TRIGGER
oscilloscope.write([
    'TRIGGER:A:EDGE:SOURCE CH1',
    'TRIGGER:A:EDGE:SLOPE RISE',
    'TRIGGER:A:TYPE EDGE',
    'TRIGGER:A:LEVEL:CH1 0e0',
    'TRIGGER:A:MODE AUTO',
], 'Setup scope trigger for CH1 edge, auto')

# Horizontal for a few RF cycles
oscilloscope.write([
    'HORIZONTAL:POSITION 50',
    'HORIZONTAL:SCALE 40E-9',
], 'Setup scope horizontal for a few cycles')

# Acquire
oscilloscope.write([
    'ACQUIRE:MODE SAMPLE',
    'ACQUIRE:STOPAFTER RUNSTOP',
    'ACQUIRE:STATE RUN',
], 'Setup scope acquire and run')
  • Might also be useful info: The data is a sin wave, 400kHz. On scope 2, it is 600 mV pk-pk, and on scope 1 it is 1.3 V pk-pk. – tylertiede Apr 01 '22 at 21:11
  • Sadly no experience with the scopes in q, but what happens if you test in the other order? I.e. can you confirm isolating the problem to the one scope? If so unless someone turns up who knows it you may be better on electronics.SE where more people are likely to know the command foibles – 2e0byo Apr 01 '22 at 21:16
  • The one thing that jumps out at me is that you're using `BANdwidth FULl` on CH1, but `BANdwidthFULl` on CH2. The lack of the space may be causing an error condition that is preventing other important settings from being activated. – jasonharper Apr 01 '22 at 21:22
  • FWIW, with a TDS 2024 I select the channel with a string of the form `f"dat:sou ch{channel}"`. You're using the longer syntax but I see that that you don't have the "ch" part. Also I get the waveform as an answer to a "wavf?" query. I assume you are using TekVisa as the low-level driver. – Paul Cornelius Apr 01 '22 at 21:27
  • 1- I am doing these tests isolated. Basically I wrote the code on scope 1, but I need it to be able to work on scope 2. They aren't being used together. – tylertiede Apr 04 '22 at 18:45
  • 2- I include the "CH" in my string input for the function. Sorry that is a little confusing. From the manual, it seems like I'm more or less doing the same as "wavf?" in my function. "[WAVFrm?] is equivalent to sending both WFMOutpre? and CURVe?..." – tylertiede Apr 04 '22 at 18:49
  • 3- I added the space for `BANdwidth FULl` and nothing changed. – tylertiede Apr 04 '22 at 18:55

0 Answers0