-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRigolDataLoggingOriginal.py
More file actions
51 lines (34 loc) · 1.17 KB
/
RigolDataLoggingOriginal.py
File metadata and controls
51 lines (34 loc) · 1.17 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
#this script just takes current data from the RIGOL DM3058E over an allotted time
import visa
import time
import csv
from visa import constants
#modify test time in seconds
testTime = 15*60
#setting up dmm conection
rm = visa.ResourceManager()
#you can receive the instrument's ID if you use print(rm.list_resources())
print(rm.list_resources())
dmm = rm.open_resource('USB0::0x1AB1::0x09C4::DM3R194201991::INSTR')
#wait for keypress to start the timer
start = input("Enter a key to start the program")
#timed loop
timeEnd = time.time() + testTime
print('Experiment has started. DO NOT CLOSE THIS WINDOW.')
count = 0
timeStart = time.time()
#writes data in a csv
with open('datapoint.csv', 'w', newline='') as csvfile:
fields = ['time', 'current']
writer = csv.DictWriter(csvfile, fieldnames=fields)
#outputs headers
writer.writeheader()
#loops until time runs out
while time.time()<timeEnd:
currTime = float(time.time() - timeStart)
dmmCurrent = float(dmm.query(":MEASure:CURRent:DC?"))
writer.writerow({'time': currTime, 'current': dmmCurrent})
#console printouts so that the user has a visible timer
print(timeEnd - time.time())
print(count)
count = count+1