0

I'm not very familiar with python. I'm compiling a python code to plot the output on the oscilloscope. But i got an error like this.

Error:

pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

Oscilloscope Model: RIGOL TECHNOLOGIES - DS2302A

Here is the code I compiled:

import pyvisa
import numpy as np
import pylab
import time
from struct import unpack
rm = pyvisa.ResourceManager() 
print(rm.list_resources())
scope = rm.open_resource('TCPIP::169.254.94.149::INSTR') # oscilloscope IP
 
scope.timeout = 10000 # ms 
scope.encoding = 'latin_1'
scope.read_termination = '\n'
scope.write_termination = '\r'
print(scope.query('*IDN?'))
scope.write('DATA:SOU CH1') 
scope.write('DATA:WIDTH 1') 
scope.write('DATA:ENC RPB')
ymult = float(scope.query('WFMPRE:YMULT?')) # y-axis least count
yzero = float(scope.query('WFMPRE:YZERO?')) # y-axis zero error
yoff = float(scope.query('WFMPRE:YOFF?')) # y-axis offset
xincr = float(scope.query('WFMPRE:XINCR?')) # x-axis least count
scope.write('CURVE?')
data = scope.read_raw() # Reading binary data
headerlen = 2 + int(data[1]) # Finding header length
header = data[:headerlen] # Separating header 
ADC_wave = data[headerlen:-1] # Separating data
ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave)) #binary to ASCII
Volts = (ADC_wave - yoff) * ymult + yzero
Time = np.arange(0, xincr * len(Volts), xincr)
# Plotting Volt Vs. Time
pylab.plot(Time, Volts) 
pylab.show()

Other people encountering the error have fixed the issues by adding a long timeout. but adding timeout didn't solve my problem. Here is the output of the pyvisa-info command in terminal.

asked Apr 25, 2023 at 13:24
2
  • Please include the error message as a code snippet in the question, rather than as a link. Commented Apr 25, 2023 at 15:28
  • 1
    I wrote the error message in the title. But I added it as a code snippet as you said. That way it was more descriptive. Thanks Commented Apr 27, 2023 at 8:59

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.