def __init__(self): self.fm = None if ps5000a is not None: scope = ps5000a.PS5000a(connect=False) self.fm = FreqMeasure(scope) else: raise Warning("Could not connect to PicoScope 5000A - can't measure frequency in aux module!")
def open_pico(powerConnected = True): ps = ps5000a.PS5000a() if powerConnected: ps.changePowerSource("PICO_POWER_SUPPLY_CONNECTED") return ps
def __init__(self, parent=None, console=None, showScriptParameter=None): super(PicoScopeInterface, self).__init__(parent) self.parent = parent self.scopetype = None self.datapoints = [] scope_cons = {} scope_cons["PS6000"] = ps6000.PS6000(connect=False) scope_cons["PS5000a"] = ps5000a.PS5000a(connect=False) scope_cons["PS2000"] = ps2000.PS2000(connect=False) defscope = scope_cons["PS5000a"] self.advancedSettings = None scopeParams = [ { 'name': 'Scope Type', 'type': 'list', 'values': scope_cons, 'value': defscope, 'set': self.setCurrentScope }, ] self.params = Parameter.create(name='PicoScope Interface', type='group', children=scopeParams) ExtendedParameter.setupExtended(self.params, self) self.showScriptParameter = showScriptParameter self.setCurrentScope(defscope)
def init_pico(self): #try: ps = ps5000a.PS5000a(self.picoscope_serialnumber) ps.resolution = ps.ADC_RESOLUTIONS["16"] #except: # DeviceInitializationFailed(self.picoscope_serial_number) for channel_name, channel_settings in self.picoscope_channel_settings.items( ): ps.setChannel(channel_name, **channel_settings) response = ps.setSamplingInterval(self.picoscope_sampling_interval, self.picoscope_duration) print 'sampling interval:', response[0] print 'number of samples:', response[1] print 'max samples:', response[2] print 'time', response[0] * response[1] self.n_samples = response[1] ps.setSimpleTrigger('External', self.picoscope_trigger_threshold, timeout_ms=self.picoscope_timeout) print('set to trigger') ps.memorySegments(self.picoscope_n_capture) ps.setNoOfCaptures(self.picoscope_n_capture) #Set Device Resolution #ps.SetResolution(self.picoscope_resolution) self.ps = ps self.ps.runBlock(pretrig=0.0, segmentIndex=0) self.ps.waitReady() self.at_init = True
def setupParameters(self): scopes = {"None":None} if ps5000a is not None: scopes["PicoScope 5000A"] = ps5000a.PS5000a(connect=False) ssParams = [{'name':'Device', 'type':'list', 'key':'device', 'values':scopes, 'value':"None", 'set':self.setConnection}] self.params = Parameter.create(name='Frequency Measurement', type='group', children=ssParams) ExtendedParameter.setupExtended(self.params, self)
def setupScope(): ps = ps5000a.PS5000a() # Example of simple capture res = ps.setSamplingFrequency(500E6, 4096) sampleRate = res[0] print("Sampling @ %f MHz, %d samples" % (res[0] / 1E6, res[1])) ps.setChannel("A", "AC", 50E-3) return [ps, sampleRate]
def initLocal(): global glbPS try: try: glbPS.getAllUnitInfo() except (NameError, TypeError, AttributeError): #is closed or never opened try: glbPS=ps5000a.PS5000a() except OSError: #has been in use elsewhere, let's hope it's not a lost reference somewhere try: del glbPS except NameError: pass import gc gc.collect() glbPS=ps5000a.PS5000a() #glbPS.quickSetup(dict(coupling="DC", VRange=2.0), nCaps=100, sampleRate=3e6, acqTime=1/60.-50e-6, resolution=15) setScopeParams() except Exception as e: print("Not using picoscope, maybe it's in use elsewhere? Exception: {}".format(e)) context = zmq.Context() global glbSOCKET_PAIR, glbSOCKET_PUBSUB glbSOCKET_PAIR = context.socket(zmq.PAIR) glbSOCKET_PAIR.set_hwm(2) glbSOCKET_PAIR.bind("tcp://*:%s" % glbPORT_PAIR) glbSOCKET_PUBSUB = context.socket(zmq.PUB) glbSOCKET_PUBSUB.set_hwm(5) glbSOCKET_PUBSUB.bind("tcp://*:%s" % glbPORT_PUBSUB) if bPLOT: import pyqtgraph as pg pg.setConfigOptions(antialias=True) #plotWin=pg.PlotWindow() #curve=plotWin.plotItem.plot() global p1, p2, plotWin plotWin=pg.GraphicsWindow(title='acquisition') p1=plotWin.addPlot() p1.plot([0,1]) plotWin.nextRow() p2=plotWin.addPlot() p2.plot([0,1]) p2.setXLink(p1)
def _open_interface(self, serial_number): open_interfaces = self._get_open_interfaces() if serial_number in open_interfaces: #raise InterfaceAlreadyOpen(serial_number) return try: ps = ps5000a.PS5000a(serial_number) except: raise InterfaceNotAvailable(serial_number) self.interfaces[serial_number] = ps
def __init__(self): AuxiliaryTemplate.__init__(self) scopes = {"None": None} self.fm = None if ps5000a is not None: scopes["PicoScope 5000A"] = ps5000a.PS5000a(connect=False) self.getParams().addChildren([{ 'name': 'Device', 'type': 'list', 'key': 'device', 'values': scopes, 'get': self.getConnection, 'set': self.setConnection }])
def examplePS6000(): fig = plt.figure() # noqa plt.ion() plt.show() print("Attempting to open...") ps = ps5000a.PS5000a() # Example of simple capture res = ps.setSamplingFrequency(250E6, 4096) sampleRate = res[0] # noqa print("Sampling @ %f MHz, %d samples" % (res[0] / 1E6, res[1])) ps.setChannel("A", "AC", 50E-3) blockdata = np.array(0) for i in range(0, 50): ps.runBlock() while (ps.isReady() is False): time.sleep(0.01) print("Sampling Done") data = ps.getDataV("A", 4096) blockdata = np.append(blockdata, data) # Simple FFT # print "FFT In Progress" # [freqs, FFTdb] = fft(data, res[0]) # plt.clf() # plt.plot(freqs, FFTdb) # plt.draw() start = (i - 5) * 4096 if start < 0: start = 0 # Spectrum Graph, keeps growing plt.clf() plt.specgram(blockdata[start:], NFFT=4096, Fs=res[0], noverlap=512) plt.xlabel('Measurement #') plt.ylabel('Frequency (Hz)') plt.draw() ps.close()
def init_pico(self): ps = ps5000a.PS5000a(self.picoscope_serialnumber) #except: # DeviceInitializationFailed(serial_number) for channel_name, channel_settings in self.picoscope_channel_settings.items(): ps.setChannel(channel_name, **channel_settings) response = ps.setSamplingInterval(self.picoscope_sampling_interval, self.picoscope_duration) print 'sampling interval:', response[0] print 'number of samples:', response[1] print 'max samples:', response[2] self.n_samples = response[1] ps.setSimpleTrigger('External', self.picoscope_trigger_threshold, timeout_ms=self.picoscope_timeout) print('set to trigger') ps.memorySegments(self.picoscope_n_capture) ps.setNoOfCaptures(self.picoscope_n_capture) self.ps = ps
""" Shows a demo of use to use the enumerate devices feature. By: Mark Harfouche """ from __future__ import division from picoscope import ps5000a import time if __name__ == "__main__": ps = ps5000a.PS5000a(connect=False) allSerialNumbers = ps.enumerateUnits() print("Found the following device serial numbers: ") for serial in allSerialNumbers: print(serial + "\n") # you can open devices by serial number serial = allSerialNumbers[0] ps = ps5000a.PS5000a(serial) # do stuff ps.flashLed(10) time.sleep(4.0) # the above flash takes roughly 4 seconds ps.close()
On my computer, it takes 2.8 seconds to open the picoscope. Maybe you want to do something useful with it :D. """ from __future__ import division from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import time from picoscope import ps5000a if __name__ == "__main__": print(__doc__) ps = ps5000a.PS5000a(connect=False) print("Attempting to open Picoscope 6000...") ps.openUnitAsync() t_start = time.time() while True: (progress, completed) = ps.openUnitProgress() print("T = %f, Progress = %d, Completed = %d" % (time.time() - t_start, progress, completed)) if completed == 1: break time.sleep(0.01) print("Completed opening the scope in %f seconds." %
def __init__(self): self.ps = ps5000a.PS5000a(connect=False)
def _get_available_interfaces(self): ps = ps5000a.PS5000a(connect=False) available_interfaces = ps.enumerateUnits() ps.close() return available_interfaces
t1 = time.time() self.capture_sweep() self.to_file(echo=True) i += 1 def disconnect(self): ''' Closes the PicoScope API, releasing the oscilloscope. ''' self.ps.close() if __name__ == '__main__': import matplotlib.pyplot as plt # picoscope = reload(picoscope) from picoscope import ps5000a # ps3000a = reload(ps3000a) ps = ps5000a.PS5000a() rscope = RadarScope(ps, max_range=1e3, range_resolution=5) rscope.capture_sweep() # rscope.to_file() # rscope.record(10, 5) plt.imshow(rscope.video_buffer, aspect="auto") plt.show() rscope.disconnect()
from picoscope import ps5000a from picoscope import picobase import matplotlib.pyplot as plt import numpy as np import time import os.path ps = ps5000a.PS5000a(serialNumber=None, connect=True) ################## Starts up the signal generator on the Picoscope ############# #pktopk: set the peak to peak voltage in microvolts """ pktopk = 20 siggen = picobase._PicoscopeBase.setSigGenBuiltInSimple(ps,offsetVoltage=0, pkToPk=pktopk, waveType="Square", frequency=5E2, shots=10000, triggerType="Rising", triggerSource="None", stopFreq=None, increment=10.0, dwellTime=1E-1, sweepType="Up", numSweeps=2) """ ps.setChannel(channel="A", coupling="AC", VRange=5) ps.setChannel(channel="C", enabled=False) ps.setChannel(channel="B", coupling="AC", VRange=0.5) ###ps.setChannel(channel="C", enabled=False) ps.setChannel(channel="D", enabled=False) ################# Adjustable Initial Conditions ################################
def __init__(self): PicoScopeBase.__init__(self, ps5000a.PS5000a(connect=False))