-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalog_input_read.py
More file actions
52 lines (36 loc) · 1.25 KB
/
analog_input_read.py
File metadata and controls
52 lines (36 loc) · 1.25 KB
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
#Benjamin Cary, bencary@mit.edu
# Commands you need before you can use the labjack with linux:
# $ sudo apt-get install build-essential
# $ sudo apt-get install libusb-1.0-0-dev
# $ sudo apt-get install git-core
# $ git clone git://github.com/labjack/exodriver.git
# $ cd exodriver/
# $ sudo ./install.sh
# $ cd ..
# $ git clone git://github.com/labjack/LabJackPython.git
# $ cd LabJackPython/
# $ sudo python setup.py install
#info on function used: https://labjack.com/support/datasheets/u3/low-level-function-reference/feedback/bitstateread
import u3, time
def read(IO_val, voltage_level):
b = u3.U3()#creates labjack interface object
#which IO location you're using
# using analog
b.configIO(FIOAnalog = 255)#sets all FIO pins to analog
init_time = 0
not_complete = True
while(not_complete):
analog_val = b.getAIN(IO_val ,32)
if(analog_val >= voltage_level):
not_complete = False
print str(init_time) + ": " + str(analog_val)
init_time += 1
time.sleep(.1)
b.close()
print("It is complete.")
#IO values
# 0-7 FIO0-FIO7
# 8-15 EIO0-EIO7
# 16-19 CIO0-CIO3
#calls the function
read(0, 0.5) #(IO value, voltage read threshhold)