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')