#!/usr/bin/env python
import numpy
import matplotlib.pyplot as plot
 
from pyusbtmc import RigolScope
 
""" Example program to plot the Y-T data from Channel 1"""
 
# Initialize our scope
test = RigolScope("/dev/usbtmc0")
 
# Stop data acquisition
test.write(":STOP")
 
# Grab the data from channel 1
test.write(":WAV:POIN:MODE NOR")
 
test.write(":WAV:DATA? CHAN1")
rawdata = test.read(9000)
data = numpy.frombuffer(rawdata, dtype='B', offset=10)
 
# Get the voltage scale
test.write(":CHAN1:SCAL?")
voltscale = float(test.read(20))
 
# And the voltage offset
test.write(":CHAN1:OFFS?")
voltoffset = float(test.read(20))
 
# Walk through the data, and map it to actual voltages
# First invert the data (ya rly)
Пример #2
0
#        tUnit = "uS"
#    elif (time[599] < 1):
#        time = time * 1e3
#        tUnit = "mS"
#    else:
#        tUnit = "S"
    return [time, data]


# Initialize our scope
test = RigolScope("/dev/usbtmc0")

plot.ion()

while 1:
    t1, d1 = getChannelData(1)
    t2, d2 = getChannelData(2)

    # Start data acquisition again, and put the scope back in local mode
    test.write(":KEY:FORC")

    # Plot the data
    plot.clf()
    plot.plot(t1, d1)
    plot.plot(t2, d2)
    plot.title("Oscilloscope data")
    plot.ylabel("Voltage (V)")
    plot.xlabel("Time (s)")
    plot.xlim(t1[0], t1[599])
    plot.draw()