I would like to address to the community a question that I don't succeed to solve.
I want to read a waveform from an oscilloscope Tek DPO 4000 series with a binary format of 2 bytes per data point. The reason is that a 1 byte per data point produces values ranged in 255 levels while 2 bytes per data point allows 65,535 discretization levels. (Actually I know that it is a 8 bits oscilloscope but when one averages, 8 bits are not enough to sample the signal, therefore I want to go for 16 bits).
Based on the code offered by Tektronix FAQ ID: 948850 (http://www.tek.com/support/faqs/program ... ope-python),
Code: Select all
import visa import numpy as np from struct import unpack import pylab scope = visa.instrument('USB0::0x0699::0x0401::No_Serial::INSTR') scope.write('DATA:SOU CH1') scope.write('DATA:WIDTH 1') scope.write('DATA:ENC RPB') ymult = float(scope.ask('WFMPRE:YMULT?')) yzero = float(scope.ask('WFMPRE:YZERO?')) yoff = float(scope.ask('WFMPRE:YOFF?')) xincr = float(scope.ask('WFMPRE:XINCR?')) scope.write('CURVE?') data = scope.read_raw() headerlen = 2 + int(data) 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) pylab.plot(Time, Volts) pylab.show()
- scope.write('DATA:WIDTH 1') to scope.write('DATA:WIDTH 2')
- ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave)) to ADC_wave = np.array(unpack('%sb' % len(ADC_wave),ADC_wave))
I also tried many other possibilities but it doesn't work too. The best I got was to have a waveform with my values separated with "0".
I would be so thankful if someone could support me with that. In my opinion it is a python issue, but I didn't find any example dealing with this case.
Thank you in advance for your help.