示例#1
0
文件: get_data.py 项目: niun/pyoscope
import sys
import os
from matplotlib import pyplot
sys.path.append(os.path.expanduser('.'))
from rigol import RigolScope
from waverunner import Waverunner
from utils import makeDataFilePath
""" Capture data from Rigol oscilloscope and write to a file 
    usage: python get_data.py <filename>
    if filename is not given STDOUT will be used"""

SCOPE_ADDRESS = 'nigpib1'

try:
    filename = sys.argv[1]
except:
    filename = makeDataFilePath()

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 = Waverunner(SCOPE_ADDRESS)
scope.grabData()
scope.writeWaveformToFile(filename)
scope.unlock()
scope.close()

示例#2
0
                               style=wx.SAVE)
        if dialog.ShowModal() == wx.ID_OK:
            filepath = dialog.GetPath()
            self.scope.writeWaveformToFile(filepath, header)
        dialog.Destroy()

    def save(self, filename):
        header = ''
        self.scope.writeWaveformToFile(filename, header)


if __name__ == '__main__':
    app = wx.PySimpleApp()
    try:
        device = sys.argv[1]
    except:
        device = 'rigol'
    if device == 'rigol':
        from rigol import RigolScope
        scope = RigolScope('/dev/usbtmc-rigol')
    elif device == 'waverunner':
        from waverunner import Waverunner
        scope = Waverunner('127.0.0.1')
    elif device == 'dummy':
        from oscope import DummyScope
        scope = DummyScope()

    app.frame = ScopePlotTestFrame(scope)
    app.frame.Show()
    app.MainLoop()
示例#3
0
#!/usr/bin/python

import matplotlib.pyplot as plt

from rigol import RigolScope

scope = RigolScope("/dev/usbtmc0")
print scope.getName()

scope.setupAndTrigger()

# Docs say that first acq gives 600 samples and second gives all of them.
# But this doesn't appear to be true.
A = scope.getWave('CHAN1')
t = scope.getWaveTime(len(A))
samp_rate = scope.askFloat(":ACQ:SAMP?")

print '%d samples' % len(A)
print 'Sampling rate is %f' % samp_rate

# Put the scope back in local mode
scope.write(":KEY:FORC")

plt.specgram(A, Fs=samp_rate)
plt.show()
示例#4
0
''' 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
import sys
import os
sys.path.append(os.path.expanduser('.'))
from rigol 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()
示例#5
0
#
# Copyright (c) 2011 Mike Hadmack
# Copyright (c) 2010 Matt Mets
# This code is distributed under the MIT license
#
#  This script is just to test rigolscope functionality as a module
#
import numpy
from matplotlib import pyplot
import sys
import os
sys.path.append(os.path.expanduser('.'))
from rigol import RigolScope

# Initialize our scope
scope = RigolScope("/dev/usbtmc0")
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):
    time = time * 1e6
    tUnit = "uS"
elif (time[599] < 1):
    time = time * 1e3
    tUnit = "mS"
else: