示例#1
0
    waveform_samples = 500

    for i, dev in enumerate(session.devices):
        # Output a sine wave for channel A voltage.
        dev.channels['A'].mode = Mode.SVMI
        dev.channels['A'].sine(0, 5, waveform_samples, -(waveform_samples / 4))
        # Output a cosine wave for channel B voltage.
        dev.channels['B'].mode = Mode.SVMI
        dev.channels['B'].sine(0, 5, waveform_samples, 0)

    chan_a = defaultdict(list)
    chan_b = defaultdict(list)

    # Run the session in noncontinuous mode.
    for _x in xrange(10):
        for i, samples in enumerate(session.get_samples(waveform_samples / 5)):
            chan_a[i].extend([x[0][0] for x in samples])
            chan_b[i].extend([x[1][0] for x in samples])

    for i, dev in enumerate(session.devices):
        plt.figure(i)
        plt.plot(chan_a[i], label='Channel A')
        plt.plot(chan_b[i], label='Channel B')
        plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
        plt.title('Device {}: {}'.format(i, str(session.devices[i])))
        plt.ylabel('Voltage')
        plt.xlabel('Sample number')

    # Show all channel voltage plots for attached devices.
    plt.show()
from __future__ import print_function

import sys

from pysmu import Session, Mode

if __name__ == '__main__':
    session = Session()

    if not session.devices:
        sys.exit(1)

    for dev in session.devices:
        dev.channels['A'].mode = Mode.SVMI
        dev.channels['B'].mode = Mode.SIMV

    for x in range(21):
        # Write 1000 samples of incrementing voltage and current values to
        # channel A and B, respectively, for every device in the session.
        v = x * (5 / 20.0)
        i = ((x * (4 / 20.0)) / 10.0) - 0.2
        data = (([v] * 1000, [i] * 1000) for dev in session.devices)
        session.write(data, cyclic=True)

        for dev, samples in enumerate(session.get_samples(10)):
            print('dev: {}: chan A voltage: {}, chan B current: {}'.format(
                dev, v, i))
            for x in samples:
                print("{: 6f} {: 6f} {: 6f} {: 6f}".format(
                    x[0][0], x[0][1], x[1][0], x[1][1]))
示例#3
0
# connected to a system.

from __future__ import print_function

import sys

from pysmu import Session, Mode


if __name__ == '__main__':
    session = Session()

    if not session.devices:
        sys.exit(1)

    for idx, dev in enumerate(session.devices):
        # Set all devices in the session to use source voltage, measure current
        # mode for channel A with a constant value based on their index.
        dev.channels['A'].mode = Mode.SVMI
        dev.channels['A'].constant(idx % 6)
        # Set all devices in the session to use source current, measure voltage
        # mode for channel B with a constant value of 0.05.
        dev.channels['B'].mode = Mode.SIMV
        dev.channels['B'].constant(0.05)

    # Run the session for at least 10 captured samples in noncontinuous mode.
    for dev_idx, samples in enumerate(session.get_samples(1000)):
        print('dev: {}'.format(dev_idx))
        for x in samples:
            print("{: 6f} {: 6f} {: 6f} {: 6f}".format(x[0][0], x[0][1], x[1][0], x[1][1]))