コード例 #1
0
# Copyright (c) 2011 Mike Hadmack
# Copyright (c) 2010 Matt Mets
# This code is distributed under the MIT license
''' realtime_plot_demo.py
    Realtime plot of both channels
    This is a fork of realtime_chart.py to use the newer RigolScope interface
    
    NOTE:  This code has not yet been adapted or tested with pyoscope
'''
import numpy
from matplotlib import pyplot
from pyusbtmc import RigolScope
import time

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

# Turn on interactive plotting
pyplot.ion()

while 1:  # How can this loop be broken other than ^C?
    # introduce a delay so that a break is recognized?
    time.sleep(0.1)

    scope.grabData()
    data1 = scope.getScaledWaveform(1)
    data2 = scope.getScaledWaveform(2)
    t = scope.getTimeAxis()

    # Start data acquisition again, and put the scope back in local mode
    scope.forceTrigger()
コード例 #2
0
# PyUSBtmc
# display_channel.py
#
# Copyright (c) 2011 Mike Hadmack
# Copyright (c) 2010 Matt Mets
# This code is distributed under the MIT license
''' realtime_plot_demo.py
    Realtime plot of both channels
    This is a fork of realtime_chart.py to use the newer RigolScope interface'''
import numpy
from matplotlib import pyplot
from pyusbtmc import RigolScope
import time

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

# Turn on interactive plotting
pyplot.ion()

while 1:  # How can this loop be broken other than ^C?
    # introduce a delay so that a break is recognized?
    time.sleep(0.1)
    
    scope.grabData()
    data1 = scope.getScaledWaveform(1)
    data2 = scope.getScaledWaveform(2)
    t = scope.getTimeAxis()

    # Start data acquisition again, and put the scope back in local mode
    scope.forceTrigger()
コード例 #3
0
#!/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)
コード例 #4
0
        time = time[0:600:1]

    # See if we should use a different time axis
#    if (time[599] < 1e-3):
#        time = time * 1e6
#        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")
コード例 #5
0
ファイル: get_data.py プロジェクト: hadmack/pyusbtmc
# PyUSBtmc
# get_data.py
#
# Copyright (c) 2011 Mike Hadmack
# This code is distributed under the MIT license
import numpy
import sys
from matplotlib import pyplot
from pyusbtmc import RigolScope

""" Capture data from Rigol oscilloscope and write to a file 
    usage: python save_channel.py <filename>
    if filename is not given STDOUT will be used"""

try:
    filename = sys.argv[1]
except:
    filename = ""

if filename == "--help":
    print """Usage: 1%s [filename]\n   Reads both traces from oscilloscope and writes as ASCII tabular data to filename.  If no filename is given the program outputs to STDOUT.  STDOUT can be directed into a file or piped into another application.  For example:\n    1%s myfile\n    1%s > myfile\n    1%s | ./plot_data.py""" % sys.argv[
        0
    ]
    sys.exit(1)

print filename
scope = RigolScope("/dev/usbtmc0")
scope.grabData()
scope.writeWaveformToFile(filename)
scope.close()
コード例 #6
0
#!/usr/bin/env python
#
# PyUSBtmc
# display_channel.py
#
# Copyright (c) 2011 Mike Hadmack
# Copyright (c) 2010 Matt Mets
# This code is distributed under the MIT license
import numpy
from matplotlib import pyplot
from pyusbtmc import RigolScope
""" Example program to plot the Y-T data from one scope channel
    derived from capture_channel_1.py but using new interface methods """
 
# Initialize our scope
scope = RigolScope("/dev/usbtmc-rigol")
 
# Stop data acquisition
scope.stop()
    
#scope.setWavePointsMode('NORM')
scope.grabData()

data1 = scope.getScaledWaveform(1)
data2 = scope.getScaledWaveform(2)

# Now, generate a time axis.
time = scope.getTimeAxis() 
 
# See if we should use a different time axis
if (time[599] < 1e-3):