Esempio n. 1
0
and use another experiment to generate the signal"""

import os
import time
import matplotlib.pyplot as plt
from opendaq import DAQ, ExpMode, Gains

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

# Configure the first experiment, the one that will be plotted
data_rate = 20
stream1 = daq.create_stream(ExpMode.ANALOG_IN, data_rate, continuous=True)
stream1.analog_setup(pinput=8, gain=Gains.S.x1)

# Configure the second experiment, a custom signal generated from a stream
preload_buffer = [-2.5, -1, 0, 1, 2.5]
stream2 = daq.create_stream(ExpMode.ANALOG_OUT, period=500,
                           npoints=len(preload_buffer), continuous=True)
stream2.load_signal(preload_buffer)

# Initiate lists and variables
t0 = 0.0
t = []
data = []

# Initiate the plot
fig = plt.figure()
Esempio n. 2
0
from __future__ import print_function
import time
import os
from opendaq import DAQ, ExpMode, Gains, Trigger

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

# Set Analog voltage
daq.set_analog(0.9)

stream1 = daq.create_stream(ExpMode.ANALOG_IN,
                            200,
                            npoints=20,
                            continuous=False)
stream1.analog_setup(pinput=8, ninput=7, gain=Gains.S.x1)

# Configure trigger (Digital input D1, value = 0 falling edge)
stream1.trigger_setup(Trigger.DIN1, 0)

daq.start()

print("Waiting for trigger...")

while daq.is_measuring:
    time.sleep(1)
    data1 = stream1.read()
    if data1:
        print("data1", data1)
generate it through the analog output"""

from __future__ import print_function
import os
import time
from opendaq import DAQ, ExpMode, Gains

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

# create a ramp signal with 4 samples
signal = list(range(4))

stream1 = daq.create_stream(ExpMode.ANALOG_IN, 300, npoints=len(signal))
stream1.analog_setup(pinput=8, gain=Gains.S.x1)

stream2 = daq.create_stream(ExpMode.ANALOG_OUT, 300, npoints=len(signal))
stream2.load_signal(signal)

daq.start()

while daq.is_measuring:
    time.sleep(1)

print("data1", stream1.read())

daq.stop()
from __future__ import print_function
import os
import time
from opendaq import DAQ, ExpMode, Gains

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

# Set Analog voltage
daq.set_analog(0.9)

stream1 = daq.create_stream(ExpMode.ANALOG_IN, 200, continuous=True)
stream1.analog_setup(pinput=8, gain=Gains.S.x1)

stream2 = daq.create_stream(ExpMode.ANALOG_IN, 300, continuous=True)
stream2.analog_setup(pinput=7, gain=Gains.S.x1)

daq.start()

for i in range(4):
    time.sleep(1)
    print("data1: ", stream1.read())
    print("data2: ", stream2.read())

daq.stop()
daq.close()
Esempio n. 5
0
import os
import time
import matplotlib.pyplot as plt
from opendaq import DAQ, ExpMode, Gains

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

daq.set_analog(1)  # set a fix voltage

# Configure the experiment
data_rate = 200
stream = daq.create_stream(ExpMode.ANALOG_IN, data_rate, continuous=True)
stream.analog_setup(pinput=8, gain=Gains.S.x1)

# Initiate lists and variables
t0 = 0.0
t = []
data = []

# Initiate the plot
fig = plt.figure()
plt.ion()
plt.show()

# start the experiment
daq.start()
Esempio n. 6
0
from __future__ import print_function
import os
import time
from opendaq import DAQ, ExpMode, Gains

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

# Set Analog voltage
daq.set_analog(0.9)

stream1 = daq.create_stream(ExpMode.ANALOG_IN, 200, npoints=20)
stream1.analog_setup(pinput=8, gain=Gains.S.x1)

stream2 = daq.create_stream(ExpMode.ANALOG_IN, 300, npoints=20)
stream2.analog_setup(pinput=7, gain=Gains.S.x1)

daq.start()

while daq.is_measuring:
    time.sleep(1)
    print("data1: ", stream1.read())
    print("data2: ", stream2.read())

print("start Again!")

daq.start()
from __future__ import print_function
import os
import time
from opendaq import DAQ, ExpMode, Gains

# Change here the serial port in which the openDAQ is connected
port = '/dev/ttyUSB0' if os.name == 'posix' else 'COM3'

# Connect to the device
daq = DAQ(port)

# Set Analog voltage
daq.set_analog(0.9)

stream1 = daq.create_stream(ExpMode.ANALOG_IN, 1, 10, continuous=False)
stream1.analog_setup(pinput=8, gain=Gains.S.x1)

stream2 = daq.create_stream(ExpMode.ANALOG_IN, 1, 20, continuous=False)
stream2.analog_setup(pinput=7, ninput=8, gain=Gains.S.x1)

daq.start()

while daq.is_measuring:
    time.sleep(0.1)

data1 = stream1.read()
data2 = stream2.read()

daq.stop()
daq.close()