-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest
100 lines (79 loc) · 1.93 KB
/
Test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon May 14 14:01:34 2018
@author: Mitch
"""
import traceback
from datetime import datetime
import matplotlib.pyplot as plt
#import matplotlib.animation as animation
#import numpy as np
from drawnow import drawnow
#from IPython import get_ipython
from multiprocessing import Process
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import random
'''
Import and open LabJack U3 package
'''
import u3
d=u3.U3() #open
'''
Set all channels to analog
'''
d.configIO(FIOAnalog = 31)
'''
Number of packets to be read.
'''
Max_Requests = 100
'''
Get calibration data
'''
d.getCalibrationData()
'''
Set the stream parameters: 1 channel, positive channel #0,
negative channel #31 ==single ended, resolutaion 3 == faster but higher noise.
Sample rate = scanrate * numchannels, max 50k samples/s.
Samples per packet = 25 for data tranfer efficiency
'''
packetsPerRequest = 50
print('Configuring U3 Stream...')
d.streamConfig(NumChannels=1,PChannels=[0],NChannels=[31],Resolution=1,\
ScanFrequency=10000,SamplesPerPacket=25)
'''
Use "try" to prevent program crash with errors.
'''
d.streamStart()
rawDataList = []
runTimeList = []
start = datetime.now()
print('Started stream at ',datetime.now(),'\n') #print the scan start time
'''
Initialize Counters
'''
missed = 0
dataCount = 0
packetCount = 0
''' Try Live plotting data'''
app = QtGui.QApplication([])
p = pg.plot()
curve = p.plot()
data = []
for r in d.streamData():
def updater():
data.append(rawDataList)
curve.setData(data)
timer = QtCore.QTimer()
timer.timeout.connect(updater)
timer.start(0)
d.streamStop()
stop = datetime.now()
print('\n','Stream stopped at ',datetime.now(),'\n')
'''close u3'''
d.close()
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()