Skip to content

Commit 1d835d3

Browse files
committedDec 6, 2017
Changed example code
1 parent e0f20ae commit 1d835d3

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed
 

‎test_dps.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
import pydps,time
22

33
# dps Test Example
4+
dps = pydps.dps_psu('COM11', 1) # port name, slave address (in decimal)
5+
6+
#make a csv like measurement
7+
def measureSteps(start,stop,step):
8+
9+
with open('results.csv', 'a') as csv: # open csv file and append
10+
for v in range(int(start*1000),int((step+stop)*1000),int(step*1000)):
11+
dps.setVoltage(v*0.001)
12+
time.sleep(0.5) #wait for stable voltage
13+
dat=dps.getFullData()
14+
print(str(dat['u-out'])+"V, "+str(dat['i-out'])+"A")
15+
csv.write(str(dat['u-out']) + ',' + str(dat['i-out'])+"\n")
16+
417

518
def main():
6-
dps = pydps.dps_psu('COM3', 1) # port name, slave address (in decimal)
19+
with open('results.csv', 'w') as csv:
20+
csv.write("u-out,i-out\n")
21+
22+
dps.setKeyLock(True)
723
print(dps.getModel())
8-
print(dps.getFullData())
24+
925
dps.setVoltage(0)
1026
dps.setOutput(True)
11-
for v in range(0,1400,50):
12-
dps.setVoltage(v*0.01)
13-
time.sleep(0.25) #wait for stable voltage
14-
dat=dps.getFullData()
15-
print(str(dat["i-out"]) + 'A ' + str(dat['u-out']) + 'V')
27+
measureSteps(start=0,stop=15,step=0.25)
28+
1629
dps.setOutput(False)
30+
dps.setKeyLock(False)
1731

32+
print("Finished")
1833

1934
if __name__ == "__main__":
2035
main()

0 commit comments

Comments
 (0)
Please sign in to comment.