Hello @digi,
I've tried running your example and replaced with tek.query() but there seems to be an issue when running on my TD540C. Do you know what could be wrong in the attached python code and why these errors
Python programimport pyvisa
import numpy as np
rm = pyvisa.ResourceManager()
rm.list_resources()
tek = rm.open_resource('GPIB0::1::INSTR')
tek.write_termination = '\n'
tek.read_termination = '\n'
print(' ')
print(tek.query('*IDN?'))
print(' ')
# configure the data format
# no header
# verbose off
# 1 byte per data point
# use binary encoding
# signed integer binaray data
# use MSB
tek.write('HEAD OFF;VERB OFF;WFMP:BYT_N 1;WFMP:ENC BIN;WFMP:BN_F RI;WFMP:BYT_O MSB')
# source = CH1, CH2, etc
tek.write('DATa:SOUrce CH2')
# get raw trace data and convert to a numpy array
raw_trace_data = np.array(map(float, tek.query('CURV?').split(',')))
# vertical gain
vgain = float(tek.query('WFMP:YMU?'))
# horizontal internval
horizontal_interval = float(tek.query('WFMP:XIN?'))
# multiply data by vertical gain
# data should contain the vertical offset
trace_data = raw_trace_data * vgain
# construct time axis
#t_axis = np.arange(len(data)) * horizontal_interval
Terminal reportmacbook-air-de-tantratron-2:~ tantratron$ source /opt/anaconda3/bin/activate
conda activate base
(base) macbook-air-de-tantratron-2:~ tantratron$ conda activate base
(base) macbook-air-de-tantratron-2:~ tantratron$ /opt/anaconda3/bin/python /Users/tantratron/Dropbox/TDS-GPIB-PyVISA/TDS540C-Induction-Lamp3.py
TEKTRONIX,TDS 540C,0,CF:91.1CT FV:v5.2e
Traceback (most recent call last):
File "/Users/tantratron/Dropbox/TDS-GPIB-PyVISA/TDS540C-Induction-Lamp3.py", line 27, in <module>
raw_trace_data = np.array(map(float, tek.query('CURV?').split(',')))
File "/opt/anaconda3/lib/python3.7/site-packages/pyvisa/resources/messagebased.py", line 613, in query
return self.read()
File "/opt/anaconda3/lib/python3.7/site-packages/pyvisa/resources/messagebased.py", line 427, in read
message = self._read_raw().decode(enco)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x88 in position 808340: ordinal not in range(128)
(base) macbook-air-de-tantratron-2:~ tantratron$
Thanks, Albert