-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathled_array_controller.py
More file actions
103 lines (53 loc) · 1.46 KB
/
led_array_controller.py
File metadata and controls
103 lines (53 loc) · 1.46 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
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
#!/usr/bin/env python
# coding: utf-8
# # LED Array Controller
# ## For use with Tektronix PWS4305
# In[2]:
import power_supply_controller as psc
# In[8]:
class LedArray( psc.PowerSupply ):
def __init__( self, timeout = 10, rid = None ):
psc.PowerSupply.__init__( self, timeout, rid )
self.__intensity = 0
# model found by curve fitting intensity using reference cell
self.__itoc = lambda i: (
0.69688698* i**(2)
+ 1.84788684* i
- 0.1645259* i**(1/2)
+ 0.0785805* i**(1/3)
)
#--- public methods ---
@property
def intensity( self ):
return self.__intensity
@intensity.setter
def intensity( self, val ):
# safety
if val > 1.1:
raise ValueError( 'Intensity too high' )
elif val < 0:
raise ValueError( 'Invalid intensity, below zero' )
self.__intensity = val
self.current = self.__itoc( val )
@property
def model( self ):
return self.__itoc
def connect( self ):
psc.PowerSupply.connect( self )
# initialize power supply
self.off()
self.voltage = 21.5 # highest allowed voltage
# In[12]:
lac = LedArray()
# In[13]:
lac.connect()
lac.id
# In[16]:
del lac
# In[14]:
lac.intensity = 0.1
# In[15]:
lac.on()
# In[57]:
# lac.off()
# In[ ]: