-
Notifications
You must be signed in to change notification settings - Fork 5
/
PS_GW_PPT1830.py
72 lines (53 loc) · 1.41 KB
/
PS_GW_PPT1830.py
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
#!/usr/bin/env python
"""
For power supply GW Instek PPT1830 GPIB commands
Using PyVisa and Python 2.7.5
This file is part of RF_Tuning_Tool.
:copyright: (c) 2013 by the A-mao Chang (maomaoto@gmail.com)
:license: MIT, see COPYING for more details.
"""
from visa import *
import time
from decimal import *
from WCDMA_attributes import *
class PS_GW_PPT1830(Instrument):
"""
class for PS_GW_PPT1830
"""
def __init__(self, resource_name, **keyw):
super(PS_GW_PPT1830, self).__init__(resource_name, **keyw)
def __repr__(self):
return "PS_GW_PPT1830({0})".format(self.resource_name)
def identity(self):
"""
return instrument name
"""
s = self.ask("*IDN?")
return s
def read_current(self, count=10):
"""
return output current in mA (int)
"""
current = 0
for i in range(count):
temp = float(self.ask("MEASure:CURRent?"))
current += temp
#print("current:{0}".format(temp))
current = int(current/count*1000)
return current
if __name__ == "__main__":
power_supply = PS_GW_PPT1830("GPIB::8")
power_supply.timeout = 10
print("*IDN?")
print(power_supply.ask("*IDN?"))
print(power_supply.identity())
a = 0
print("average:{0}".format(power_supply.read_current()))
"""
for i in range(10):
current = power_supply.read_current()
a += current
print("current:{0}".format(current))
print("average:{0:.3f}".format(a/10))
print("average:{0}".format(a/10))
"""