Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
def run_picoscope(sampling_interval, duration, channel, coupling, v_range,
                  v_offset):
    """ Run the picoscope and save the results to database. Returns the readingSet db object"""

    ps = ps2000.PS2000()

    (actualSamplingInterval, nSamples, maxSamples) = \
        ps.setSamplingInterval(sampleInterval=sampling_interval, duration=duration)
    ps.setChannel(channel,
                  coupling,
                  v_range,
                  v_offset,
                  enabled=True,
                  BWLimited=False)
    ps.setSimpleTrigger('A', 1.0, 'Falling', timeout_ms=100, enabled=True)

    ps.setSigGenBuiltInSimple(offsetVoltage=0,
                              pkToPk=1.2,
                              waveType="Sine",
                              frequency=50E3)

    # Create a new readings set to hold the results
    rs = ReadingSet(start=datetime.now(),
                    block_duration=duration,
                    requested_sampling_interval=sampling_interval,
                    actual_sampling_interval=actualSamplingInterval,
                    samples_number=nSamples,
                    maximum_samples=maxSamples,
                    coupling=coupling,
                    v_range=v_range,
                    v_offset=v_offset)
    db.session.add(rs)
    db.session.commit()

    ps.runBlock()
    ps.waitReady()
    print("Waiting for awg to settle.")
    time.sleep(2.0)
    ps.runBlock()
    ps.waitReady()
    print("Done waiting for trigger")
    dataA = ps.getDataV('A', nSamples, returnOverflow=False)

    dataTimeAxis = np.arange(nSamples) * actualSamplingInterval
    ps.stop()
    ps.close()
    print("Connection closed.")

    for i in range(0, len(dataA)):
        reading = Reading(set_id=rs.id,
                          value=dataA[i],
                          time_delta=dataTimeAxis[i])
        db.session.add(reading)
    db.session.commit()

    return rs
Ejemplo n.º 3
0
def open_pico():
    print("Attempting to open Picoscope 2000...")

    ps = ps2000.PS2000()
    # Uncomment this line to use with the 2000a/2000b series
    # ps = ps2000a.PS2000a()

    print("Found the following picoscope:")
    print(ps.getAllUnitInfo())
    return ps
Ejemplo n.º 4
0
def test():
    import time
    from picoscope import ps2000

    import numpy as np

    ps = ps2000.PS2000()

    waveform_desired_duration = 50E-3
    obs_duration = 3 * waveform_desired_duration
    sampling_interval = obs_duration / 4096

    (actualSamplingInterval, nSamples,
     maxSamples) = ps.setSamplingInterval(sampling_interval, obs_duration)
    channelRange = ps.setChannel('A',
                                 'DC',
                                 2.0,
                                 0.0,
                                 enabled=True,
                                 BWLimited=False)
    #ps.setSimpleTrigger('A', 1.0, 'Falling', timeout_ms=100, enabled=True)

    #ps.setSigGenBuiltInSimple(offsetVoltage=0, pkToPk=1.2, waveType="Sine", frequency=50E3)

    ps.runBlock()
    ps.waitReady()
    print("Waiting for awg to settle.")
    time.sleep(2.0)
    ps.runBlock()
    ps.waitReady()
    print("Done waiting for trigger")
    dataA = ps.getDataV('A', nSamples, returnOverflow=False)

    dataTimeAxis = np.arange(nSamples) * actualSamplingInterval

    ps.stop()
    ps.close()
    print("Connection closed.")

    #dataA= [1,2,3]
    #dataTimeAxis = [4,5,6]

    print(dataA)
    print(dataTimeAxis)

    return render_template('default/test.html',
                           values=dataA,
                           labels=dataTimeAxis)
Ejemplo n.º 5
0
 def __init__(self):
     self.scope = ps2000.PS2000()
     waveform_desired_duration = 200E-3
     obs_duration = 3 * waveform_desired_duration
     sampling_interval = obs_duration / 4096
     (self.actualSamplingInterval, self.nSamples, maxSamples) = \
         self.scope.setSamplingInterval(sampling_interval, obs_duration)
     print('actual sampling interval = ', self.actualSamplingInterval)
     print('nsamples = ', self.nSamples)
     self.scope.setChannel('A', 'AC', 2.0, 0.0, enabled=True,
                        BWLimited=False)
     self.scope.setSimpleTrigger('A', 0, 'Falling', timeout_ms=100,
                              enabled=True)
     self.scope.setChannel('B', 'AC', 2.0, 0.0, enabled=True, BWLimited=False)
     self.scope.setSimpleTrigger('B', 0, 'Falling', timeout_ms=100,
                              enabled=True)
Ejemplo n.º 6
0
    def initialisation_picoscope_2000(self):
        print("initiatisation picoscope 2000")
        self.ps = ps2000.PS2000()
        # Uncomment this line to use with the 2000a/2000b series
        # ps = ps2000a.PS2000a()

        print("Found the following picoscope:")

        self.ps.getAllUnitInfo()
        time.sleep(5)
        waveform_desired_duration = 10E-6
        obs_duration = 3 * waveform_desired_duration
        sampling_interval = obs_duration / 4096

        (actualSamplingInterval, self.nSamples, maxSamples) = \
            self.ps.setSamplingInterval(sampling_interval, obs_duration)
        print("Sampling interval = %f ns" % (actualSamplingInterval * 1E9))
        print("Taking  samples = %d" % self.nSamples)
        print("Maximum samples = %d" % maxSamples)

        # the setChannel command will chose the next largest amplitude
        channelRange = self.ps.setChannel('A',
                                          'DC',
                                          2.0,
                                          0.0,
                                          enabled=True,
                                          BWLimited=False)
        print("Chosen channel range = %d" % channelRange)

        self.ps.setSimpleTrigger('A',
                                 1.0,
                                 'Falling',
                                 timeout_ms=100,
                                 enabled=True)

        self.ps.setSigGenBuiltInSimple(offsetVoltage=0,
                                       pkToPk=1.2,
                                       waveType="Sine",
                                       frequency=50E3)
        self.picoscope_selected = "picoscope_2000"
        self.start()
Ejemplo n.º 7
0
    def __init__(self, OscilloscopeType="A", printFunction=print):

        printFunction("Attempting to open Picoscope 2000...")

        if oscilloscopeType == "A":
            self.ps = ps2000a.PS2000a(
            )  # Uncomment this line to use with the 2000a/2000b series
        elif oscilloscopeType == "B":
            self.ps = ps2000.PS2000()
        else:
            printFunction("You must choose proper communication type")

        if oscilloscopeType == "A" or oscilloscopeType == "B":
            printFunction("Found the following picoscope:")
            printFunction(self.ps.getAllUnitInfo())
            self.ranges = [2.0, 1.0, 0.5, 0.2, 0.1, 0.05
                           ]  # oscilloscope ranges available form measurement
            self.connected = True
            self.samplesPerObservation = 16384
            self.currentRange = self.ranges[0]
            self.nSamples = 0
Ejemplo n.º 8
0
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import time
from picoscope import ps2000
# from picoscope import ps2000a
import pylab as plt
import numpy as np

if __name__ == "__main__":
    print(__doc__)

    print("Attempting to open Picoscope 2000...")

    ps = ps2000.PS2000()
    # Uncomment this line to use with the 2000a/2000b series
    # ps = ps2000a.PS2000a()

    print("Found the following picoscope:")
    print(ps.getAllUnitInfo())

    waveform_desired_duration = 50E-6
    obs_duration = 3 * waveform_desired_duration
    sampling_interval = obs_duration / 4096

    (actualSamplingInterval, nSamples, maxSamples) = \
        ps.setSamplingInterval(sampling_interval, obs_duration)
    print("Sampling interval = %f ns" % (actualSamplingInterval * 1E9))
    print("Taking  samples = %d" % nSamples)
    print("Maximum samples = %d" % maxSamples)
Ejemplo n.º 9
0
 def __init__(self):
     PicoScopeBase.__init__(self, ps2000.PS2000(connect=False))