here is the code sample, ive been using matplotlib and pyvisa
try:
tex = tektronixOscope(source)
print("Getting offsets...")
tex.getOffsets()
armed = tex.armed
auto = tex.auto
ready = tex.ready
save = tex.save
trigger = tex.trigger
print("Checking trigger status...")
state = tex.checkTrigger()
plt.ion()
fig = plt.figure()
triggerCount = 0
checkCount = 1
# start = Time.time()
# while((Time.time()-start) > 30):
while(True):
if(tex.state == tex.trigger):
triggerCount+=1
print ("Scope has triggered %d/%d, reading out data now" % (triggerCount,checkCount))
print (tex.readData())
[time,volts] = tex.unpackData()
plt.plot(time,volts)
plt.show()
plt.pause(0.0001)
.....
def unpackData(self):
headerlen = 2 + int(self.data[1])
header = self.data[:headerlen]
ADC_wave = self.data[headerlen:-1]
ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave))
self.volts = (ADC_wave - self.yoff)*self.ymult + self.yzero
self.time = np.arange(0,self.xincr*len(self.volts),self.xincr)
return [self.time,self.volts]
The problem with this code, is that it constantly gives me the following error message:
"x and y must have same first dimension, but have shapes (999953,) and (999952)
I have checked the equations multiple times but I still don't understand what is wrong. have looked into questions with a similar problem but im still unable
error message Traceback (most recent call last): File "C:\Users\mnowshad\Documents\New folder\pyvis.py", line 136, in main(source) File "C:\Users\mnowshad\Documents\New folder\pyvis.py", line 34, in main plt.plot(time,volts) File "C:\Users\mnowshad\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\pyplot.py", line 2728, in plot return gca().plot( File "C:\Users\mnowshad\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes_axes.py", line 1662, in plot lines = [*self._get_lines(*args, data=data, **kwargs)] File "C:\Users\mnowshad\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes_base.py", line 311, in call yield from self._plot_args( File "C:\Users\mnowshad\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes_base.py", line 504, in _plot_args raise ValueError(f"x and y must have same first dimension, but " ValueError: x and y must have same first dimension, but have shapes (1,) and (999952,)
C:\Users\mnowshad\Documents\New folder>^Z