spirack 0.2.18__tar.gz → 0.2.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spirack-0.2.18 → spirack-0.2.20}/PKG-INFO +1 -1
- {spirack-0.2.18 → spirack-0.2.20}/spirack/D5a_module.py +24 -24
- {spirack-0.2.18 → spirack-0.2.20}/spirack/M2p_module.py +138 -114
- spirack-0.2.20/spirack/version.py +1 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack.egg-info/PKG-INFO +1 -1
- spirack-0.2.18/spirack/version.py +0 -1
- {spirack-0.2.18 → spirack-0.2.20}/LICENSE +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/README.md +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/setup.cfg +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/setup.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/B1b_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/B2b_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/D4_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/D4a_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/D4b_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/D5b_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/F1d_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/M2j_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/P2d_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/S4g_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/S5i_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/S5k_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/S5l_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/U1c_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/U2_module.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/__init__.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/chip_mode.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack/spi_rack.py +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack.egg-info/SOURCES.txt +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack.egg-info/dependency_links.txt +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack.egg-info/requires.txt +0 -0
- {spirack-0.2.18 → spirack-0.2.20}/spirack.egg-info/top_level.txt +0 -0
|
@@ -44,8 +44,8 @@ class D5a_module(object):
|
|
|
44
44
|
|
|
45
45
|
# DAC software span constants
|
|
46
46
|
range_4V_uni = 0
|
|
47
|
-
range_4V_bi = 2
|
|
48
47
|
range_8V_uni = 1
|
|
48
|
+
range_4V_bi = 2
|
|
49
49
|
range_8V_bi = 3
|
|
50
50
|
range_2V_bi = 4
|
|
51
51
|
|
|
@@ -67,7 +67,7 @@ class D5a_module(object):
|
|
|
67
67
|
self.spi_rack = spi_rack
|
|
68
68
|
self.module = module
|
|
69
69
|
self._num_dacs = num_dacs
|
|
70
|
-
self.
|
|
70
|
+
self.spans = [np.nan]*self._num_dacs
|
|
71
71
|
self.voltages = [np.nan]*self._num_dacs
|
|
72
72
|
|
|
73
73
|
for i in range(self._num_dacs):
|
|
@@ -108,7 +108,7 @@ class D5a_module(object):
|
|
|
108
108
|
if DAC not in range(self._num_dacs):
|
|
109
109
|
raise ValueError('D5a module {} [change_span_update]: DAC {} does not exist.'.format(self.module, DAC))
|
|
110
110
|
|
|
111
|
-
self.
|
|
111
|
+
self.spans[DAC] = span
|
|
112
112
|
|
|
113
113
|
# Determine which DAC in IC by checking even/uneven
|
|
114
114
|
address = (DAC%2)<<1
|
|
@@ -130,7 +130,7 @@ class D5a_module(object):
|
|
|
130
130
|
# The change of span will also cause a change in the actual output voltage
|
|
131
131
|
# Make update to the voltages array to reflect that change
|
|
132
132
|
new_settings = self.get_settings(DAC) # read from actual hardware
|
|
133
|
-
self.
|
|
133
|
+
self.voltages[DAC] = new_settings[0] # update to the cached variables
|
|
134
134
|
|
|
135
135
|
def change_span(self, DAC, span):
|
|
136
136
|
"""Changes the software span of selected DAC without update
|
|
@@ -148,7 +148,7 @@ class D5a_module(object):
|
|
|
148
148
|
if DAC not in range(self._num_dacs):
|
|
149
149
|
raise ValueError('D5a module {} [change_span]: DAC {} does not exist.'.format(self.module, DAC))
|
|
150
150
|
|
|
151
|
-
self.
|
|
151
|
+
self.spans[DAC] = span
|
|
152
152
|
|
|
153
153
|
# Determine which DAC in IC by checking even/uneven
|
|
154
154
|
address = (DAC%2)<<1
|
|
@@ -272,27 +272,27 @@ class D5a_module(object):
|
|
|
272
272
|
|
|
273
273
|
step = self.get_stepsize(DAC)
|
|
274
274
|
|
|
275
|
-
if self.
|
|
275
|
+
if self.spans[DAC] == D5a_module.range_4V_uni:
|
|
276
276
|
bit_value = int(round(voltage / step))
|
|
277
277
|
self.voltages[DAC] = bit_value * step
|
|
278
278
|
maxV = 4.0
|
|
279
279
|
minV = 0.0
|
|
280
|
-
elif self.
|
|
280
|
+
elif self.spans[DAC] == D5a_module.range_4V_bi:
|
|
281
281
|
bit_value = int(round((voltage + 4.0) / step))
|
|
282
282
|
self.voltages[DAC] = (bit_value * step) - 4.0
|
|
283
283
|
maxV = 4.0
|
|
284
284
|
minV = -4.0
|
|
285
|
-
if self.
|
|
285
|
+
if self.spans[DAC] == D5a_module.range_8V_uni:
|
|
286
286
|
bit_value = int(round(voltage / step))
|
|
287
287
|
self.voltages[DAC] = bit_value * step
|
|
288
288
|
maxV = 8.0
|
|
289
289
|
minV = 0.0
|
|
290
|
-
elif self.
|
|
290
|
+
elif self.spans[DAC] == D5a_module.range_8V_bi:
|
|
291
291
|
bit_value = int(round((voltage + 8.0) / step))
|
|
292
292
|
self.voltages[DAC] = (bit_value * step) - 8.0
|
|
293
293
|
maxV = 8.0
|
|
294
294
|
minV = -8.0
|
|
295
|
-
elif self.
|
|
295
|
+
elif self.spans[DAC] == D5a_module.range_2V_bi:
|
|
296
296
|
bit_value = int(round((voltage + 2.0) / step))
|
|
297
297
|
self.voltages[DAC] = (bit_value * step) - 2.0
|
|
298
298
|
maxV = 2.0
|
|
@@ -331,16 +331,16 @@ class D5a_module(object):
|
|
|
331
331
|
if DAC not in range(self._num_dacs):
|
|
332
332
|
raise ValueError('D5a module {} [get_stepsize]: DAC {} does not exist.'.format(self.module, DAC))
|
|
333
333
|
|
|
334
|
-
if self.
|
|
335
|
-
return 4.0
|
|
336
|
-
elif self.
|
|
337
|
-
return 8.0
|
|
338
|
-
elif self.
|
|
339
|
-
return 16.0
|
|
340
|
-
elif self.
|
|
341
|
-
return 4.0
|
|
334
|
+
if self.spans[DAC] == D5a_module.range_4V_uni:
|
|
335
|
+
return 4.0/(2**18)
|
|
336
|
+
elif (self.spans[DAC] == D5a_module.range_4V_bi or self.spans[DAC] == D5a_module.range_8V_uni):
|
|
337
|
+
return 8.0/(2**18)
|
|
338
|
+
elif self.spans[DAC] == D5a_module.range_8V_bi:
|
|
339
|
+
return 16.0/(2**18)
|
|
340
|
+
elif self.spans[DAC] == D5a_module.range_2V_bi:
|
|
341
|
+
return 4.0/(2**18)
|
|
342
342
|
else:
|
|
343
|
-
raise ValueError(
|
|
343
|
+
raise ValueError("Span for DAC ",DAC," is not a valid value. The span is currently set to ".self.span[DAC],".")
|
|
344
344
|
|
|
345
345
|
def get_settings(self, DAC):
|
|
346
346
|
"""Reads current DAC settings
|
|
@@ -362,14 +362,14 @@ class D5a_module(object):
|
|
|
362
362
|
DAC_ic = DAC//2
|
|
363
363
|
|
|
364
364
|
# Read code command
|
|
365
|
-
command = 0b1101
|
|
365
|
+
command = 0b1101 # 0xd
|
|
366
366
|
data = bytearray([(command<<4) | address, 0, 0, 0])
|
|
367
367
|
|
|
368
368
|
code_data = self.spi_rack.read_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_RD_SPEED, data)
|
|
369
369
|
code = (code_data[1]<<10) | (code_data[2]<<2) | (code_data[3]>>6)
|
|
370
370
|
|
|
371
371
|
# Read span command
|
|
372
|
-
command = 0b1100
|
|
372
|
+
command = 0b1100 # 0xc
|
|
373
373
|
data = bytearray([(command<<4) | address, 0, 0, 0])
|
|
374
374
|
|
|
375
375
|
span_data = self.spi_rack.read_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_RD_SPEED, data)
|
|
@@ -389,8 +389,8 @@ class D5a_module(object):
|
|
|
389
389
|
raise ValueError("Span {} should not be used. Accepted values are: {}".format(span, [0, 1, 2, 3, 4]))
|
|
390
390
|
|
|
391
391
|
self.voltages[DAC] = voltage
|
|
392
|
-
self.
|
|
393
|
-
|
|
392
|
+
self.spans[DAC] = span
|
|
393
|
+
|
|
394
394
|
return [voltage, span]
|
|
395
395
|
|
|
396
396
|
def is_D5a_communicating(self):
|
|
@@ -429,4 +429,4 @@ class D5a_module(object):
|
|
|
429
429
|
if (test_value != new_value):
|
|
430
430
|
return 0
|
|
431
431
|
else:
|
|
432
|
-
return 1
|
|
432
|
+
return 1
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
from
|
|
3
|
-
from chip_mode import BICPINS_MODE, BICPINS_SPEED
|
|
4
|
-
from time import sleep
|
|
2
|
+
from .chip_mode import BICPINS_MODE, BICPINS_SPEED
|
|
5
3
|
|
|
6
|
-
#global values
|
|
7
|
-
gainlist = [1,10,100,1000,10000]
|
|
8
4
|
|
|
9
5
|
class M2p_module(object):
|
|
10
6
|
"""M2p module interface class
|
|
@@ -22,9 +18,20 @@ class M2p_module(object):
|
|
|
22
18
|
remote_settings: contains a byte with the remote settigns (IQ gain and filter)
|
|
23
19
|
"""
|
|
24
20
|
|
|
21
|
+
#allowed gain values
|
|
22
|
+
gainlist = [1,10,100,1000,10000]
|
|
23
|
+
|
|
24
|
+
|
|
25
25
|
def __init__(self, spi_rack, module):
|
|
26
26
|
self.module = module
|
|
27
27
|
self.spi_rack = spi_rack
|
|
28
|
+
|
|
29
|
+
# Upon start-up copy the existing local settings
|
|
30
|
+
# and set module to local operation
|
|
31
|
+
initial_gain = self.get_gain_local()
|
|
32
|
+
initial_coupling = self.get_coupling_local()
|
|
33
|
+
self.remote_set_gain_and_coupling(gain = initial_gain, coupling = initial_coupling)
|
|
34
|
+
self.set_local()
|
|
28
35
|
|
|
29
36
|
def set_remote(self):
|
|
30
37
|
"""
|
|
@@ -35,29 +42,33 @@ class M2p_module(object):
|
|
|
35
42
|
# check if module is already in remote mode, if so do nothing
|
|
36
43
|
set_mode = self.get_operating_mode()
|
|
37
44
|
if (set_mode == 1):
|
|
38
|
-
print("Already in
|
|
45
|
+
print("Already in remote mode. No mode change made" )
|
|
39
46
|
return #exit do nothing
|
|
40
47
|
|
|
41
|
-
# Get
|
|
42
|
-
gain = self.
|
|
43
|
-
couple = self.
|
|
44
|
-
|
|
48
|
+
# Get the local gain and coupling settings (from the front panel) ...
|
|
49
|
+
gain = self.get_gain_local()
|
|
50
|
+
couple = self.get_coupling_local()
|
|
51
|
+
# ... and use them initially when switching to remote mode
|
|
52
|
+
self.remote_set_gain_and_coupling(gain,couple)
|
|
45
53
|
|
|
46
54
|
dummy_data = bytearray([0,0])
|
|
47
55
|
r_data = bytearray([0,0])
|
|
48
56
|
r_data = self.spi_rack.read_data(self.module, 6, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
49
57
|
|
|
50
|
-
#set remote bit
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
#set remote bit to 1 (keeping other setings)
|
|
59
|
+
high_byte = r_data[0]|0b10000000
|
|
60
|
+
#low_byte = r_data[1]|0b10000000
|
|
61
|
+
low_byte = r_data[1]
|
|
62
|
+
|
|
63
|
+
#write new settings (with high remote bit)
|
|
64
|
+
w_data = bytearray([high_byte,low_byte])
|
|
65
|
+
self.spi_rack.write_data(self.module, 5, BICPINS_MODE, BICPINS_SPEED, w_data)
|
|
66
|
+
self.remote_set_gain_and_coupling(gain,couple)
|
|
56
67
|
|
|
57
68
|
def set_local(self):
|
|
58
69
|
"""
|
|
59
|
-
Set the module to local mode. The gain- and coupling settings
|
|
60
|
-
If the remotely set gain is different from the front panel setting there
|
|
70
|
+
Set the module to local mode. The gain- and coupling settings revert to the front-panel switch setting.
|
|
71
|
+
If the remotely set gain is different from the front panel setting there might be a jump in output due to a differnce in gain.
|
|
61
72
|
"""
|
|
62
73
|
|
|
63
74
|
# read last high and low byte setting
|
|
@@ -65,209 +76,222 @@ class M2p_module(object):
|
|
|
65
76
|
r_data = bytearray([0,0])
|
|
66
77
|
r_data = self.spi_rack.read_data(self.module, 6, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
67
78
|
|
|
68
|
-
#reset remote bit
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
#reset remote bit to 0 (keeping other setings)
|
|
80
|
+
high_byte = r_data[0] & 0b01111111
|
|
81
|
+
#low_byte = r_data[1] & 0b01111111
|
|
82
|
+
low_byte = r_data[1]
|
|
71
83
|
|
|
72
|
-
#write settings with
|
|
73
|
-
|
|
74
|
-
self.spi_rack.write_data(self.module, 5, BICPINS_MODE, BICPINS_SPEED,
|
|
84
|
+
#write new settings (with 0-set remote bit)
|
|
85
|
+
w_data = bytearray([high_byte,low_byte])
|
|
86
|
+
self.spi_rack.write_data(self.module, 5, BICPINS_MODE, BICPINS_SPEED, w_data)
|
|
75
87
|
|
|
76
|
-
def
|
|
88
|
+
def remote_set_gain_and_coupling(self, gain, coupling):
|
|
77
89
|
"""
|
|
78
90
|
Set gain and coupling mode
|
|
79
91
|
Posible gain settings : 1, 10, 100, 1000, 10.000
|
|
80
|
-
Coupling DC=
|
|
92
|
+
Coupling 'DC'=1 'AC'=0
|
|
93
|
+
|
|
81
94
|
gainlevel and couplemode parameters are checked for valid values.
|
|
82
95
|
When one of the parameters is out of range or otherwise invalid no change in settings will be made
|
|
83
|
-
|
|
96
|
+
|
|
97
|
+
The remote/local selection is maintained, so under a 'local' setting NO CHANGE in gain or coupling will happen.
|
|
84
98
|
But the last written values can be readback
|
|
85
99
|
"""
|
|
86
100
|
|
|
87
|
-
# check for valid gain and
|
|
88
|
-
if self.
|
|
89
|
-
print("Invalid gain or
|
|
101
|
+
# check for valid gain and coupling values
|
|
102
|
+
if self._is_gain_valid(gain) == False or self._is_couplemode_valid(coupling) == False:
|
|
103
|
+
print("Invalid gain or coupling, no settings changed" )
|
|
90
104
|
return
|
|
91
105
|
|
|
92
|
-
# read high byte for
|
|
106
|
+
# read to preserve the value of the high byte for the upcoming 'write'
|
|
93
107
|
dummy_data = bytearray([0,0])
|
|
94
108
|
r_data = bytearray([0,0])
|
|
95
109
|
r_data = self.spi_rack.read_data(self.module, 6, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
96
|
-
|
|
110
|
+
high_byte = r_data[0]
|
|
97
111
|
|
|
98
|
-
#
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
# config gain bits
|
|
113
|
+
if gain == 1:
|
|
114
|
+
low_byte = 0b10010000
|
|
115
|
+
elif gain == 10:
|
|
116
|
+
low_byte = 0b10010001
|
|
117
|
+
elif gain == 100:
|
|
118
|
+
low_byte = 0b10010010
|
|
119
|
+
elif gain == 1000:
|
|
120
|
+
low_byte = 0b10010110
|
|
121
|
+
else:
|
|
122
|
+
# gain == 10000:
|
|
123
|
+
low_byte = 0b10011010
|
|
110
124
|
|
|
111
|
-
#
|
|
112
|
-
if
|
|
113
|
-
|
|
125
|
+
# config coupling bit (while keeping other settings)
|
|
126
|
+
if coupling == 'DC':
|
|
127
|
+
low_byte = low_byte | 0b00010000 # For DC, set control bit to 1
|
|
114
128
|
else:
|
|
115
|
-
|
|
129
|
+
low_byte = low_byte & 0b11101111 # For AC, set control bit to 0
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
self.spi_rack.write_data(self.module, 5, BICPINS_MODE, BICPINS_SPEED,
|
|
131
|
+
w_data = bytearray([high_byte,low_byte])
|
|
132
|
+
self.spi_rack.write_data(self.module, 5, BICPINS_MODE, BICPINS_SPEED, w_data)
|
|
119
133
|
|
|
120
|
-
def
|
|
134
|
+
def _is_gain_valid(self, gain):
|
|
121
135
|
# Check gain parameter for valid values
|
|
122
136
|
# return True (valid) or False (invalid)
|
|
123
|
-
if gain in gainlist:
|
|
137
|
+
if gain in self.gainlist:
|
|
124
138
|
return True
|
|
125
139
|
else:
|
|
126
140
|
return False
|
|
127
141
|
|
|
128
|
-
def
|
|
142
|
+
def _is_couplemode_valid(self, couplemode):
|
|
129
143
|
# Check couple parameter for valid values
|
|
130
144
|
# return True (valid) or False (invalid)
|
|
131
|
-
if couplemode
|
|
132
|
-
return False
|
|
133
|
-
else:
|
|
145
|
+
if couplemode in ['AC','DC']:
|
|
134
146
|
return True
|
|
147
|
+
else:
|
|
148
|
+
return False
|
|
135
149
|
|
|
136
150
|
def get_operating_mode(self):
|
|
137
151
|
"""
|
|
138
152
|
read the operating status of the module.
|
|
139
|
-
|
|
153
|
+
Modes can be 'remote' or 'local'
|
|
140
154
|
"""
|
|
141
155
|
|
|
142
|
-
mode =
|
|
156
|
+
mode = ''
|
|
143
157
|
dummy_data = bytearray([0,0])
|
|
144
158
|
r_data = bytearray([0,0])
|
|
145
159
|
r_data = self.spi_rack.read_data(self.module, 6, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
146
160
|
|
|
147
161
|
if r_data[0] & 0b10000000:
|
|
148
|
-
mode =
|
|
162
|
+
mode = 'remote'
|
|
149
163
|
else:
|
|
150
|
-
mode =
|
|
164
|
+
mode = 'local'
|
|
151
165
|
|
|
152
166
|
return(mode)
|
|
153
167
|
|
|
154
|
-
def
|
|
168
|
+
def get_gain_setting(self):
|
|
155
169
|
"""
|
|
156
170
|
Get lastgain switch setting command.
|
|
157
171
|
This in NOT the same as the gain settings of the switch panel!
|
|
158
172
|
This is the last gain set in remote mode.
|
|
159
|
-
|
|
173
|
+
Posible results: 1, 10, 100, 1000, 10000
|
|
160
174
|
"""
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
if self.get_operating_mode()=='local':
|
|
176
|
+
return self.get_gain_local()
|
|
177
|
+
else:
|
|
178
|
+
return self.get_gain_remote()
|
|
179
|
+
|
|
180
|
+
def get_gain_remote(self):
|
|
181
|
+
s_data = bytearray([0, 0])
|
|
164
182
|
r_data = self.spi_rack.read_data(self.module, 6, BICPINS_MODE, BICPINS_SPEED, s_data)
|
|
165
183
|
gain = -1
|
|
166
184
|
if r_data[1] & 0b00001111 == 0:
|
|
167
185
|
gain = 1
|
|
168
|
-
if r_data[1] &
|
|
186
|
+
if r_data[1] & 0b00001111 == 0b00000001:
|
|
169
187
|
gain = 10
|
|
170
|
-
if r_data[1] &
|
|
188
|
+
if r_data[1] & 0b00001111 == 0b00000010:
|
|
171
189
|
gain = 100
|
|
172
|
-
if r_data[1] &
|
|
190
|
+
if r_data[1] & 0b00001111 == 0b00000110:
|
|
173
191
|
gain = 1000
|
|
174
|
-
if r_data[1] &
|
|
192
|
+
if r_data[1] & 0b00001111 == 0b00001010:
|
|
175
193
|
gain = 10000
|
|
176
194
|
return (gain)
|
|
177
195
|
|
|
178
196
|
|
|
179
|
-
def
|
|
197
|
+
def get_gain_local(self):
|
|
180
198
|
"""
|
|
181
|
-
Get the
|
|
182
|
-
|
|
199
|
+
Get the front-panel gain switch setting.
|
|
200
|
+
Posible results: 1, 10, 100, 1000, 10000
|
|
183
201
|
"""
|
|
184
|
-
|
|
185
|
-
commandlow = 0b00000000
|
|
186
|
-
s_data = bytearray([commandhigh, commandlow])
|
|
202
|
+
s_data = bytearray([0,0])
|
|
187
203
|
r_data = self.spi_rack.read_data(self.module, 4, BICPINS_MODE, BICPINS_SPEED, s_data)
|
|
188
204
|
|
|
189
205
|
gain = -1
|
|
190
206
|
if r_data[1] & 0b00001111 == 0:
|
|
191
207
|
gain = 1
|
|
192
|
-
|
|
208
|
+
elif r_data[1] & 0b00001111 == 0b00000001:
|
|
193
209
|
gain = 10
|
|
194
|
-
|
|
210
|
+
elif r_data[1] & 0b00001111 == 0b00000010:
|
|
195
211
|
gain = 100
|
|
196
|
-
|
|
212
|
+
elif r_data[1] & 0b00001111 == 0b00000110:
|
|
197
213
|
gain = 1000
|
|
198
|
-
|
|
214
|
+
elif r_data[1] & 0b00001111 == 0b00001010:
|
|
199
215
|
gain = 10000
|
|
200
216
|
|
|
201
217
|
return (gain)
|
|
202
218
|
|
|
203
|
-
def
|
|
219
|
+
def get_coupling_setting(self):
|
|
204
220
|
"""
|
|
205
221
|
Get the last frontpanel couple mode (AC/DC) switch setting command.
|
|
206
222
|
This in NOT the same as the couple mode settings on the front panel!
|
|
207
|
-
posible results:
|
|
223
|
+
posible results: 'DC'=1 AC='0'
|
|
208
224
|
"""
|
|
225
|
+
if self.get_operating_mode()=='local':
|
|
226
|
+
return self.get_coupling_local()
|
|
227
|
+
else:
|
|
228
|
+
return self.get_coupling_remote()
|
|
229
|
+
|
|
230
|
+
def get_coupling_remote(self):
|
|
209
231
|
dummy_data = bytearray([0,0])
|
|
210
232
|
r_data = self.spi_rack.read_data(self.module, 6, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
211
233
|
mode = -1
|
|
212
234
|
if r_data[1] & 0b00010000:
|
|
213
|
-
mode =
|
|
235
|
+
mode = 'DC'
|
|
214
236
|
else:
|
|
215
|
-
mode =
|
|
237
|
+
mode = 'AC'
|
|
216
238
|
return (mode)
|
|
217
239
|
|
|
218
|
-
def
|
|
240
|
+
def get_coupling_local(self):
|
|
219
241
|
"""
|
|
220
242
|
Get the frontpanel couple mode (AC/DC) switch setting.
|
|
221
|
-
posible results:
|
|
243
|
+
posible results: 'DC'=1 AC='0'
|
|
222
244
|
"""
|
|
223
245
|
dummy_data = bytearray([0,0])
|
|
224
246
|
r_data = self.spi_rack.read_data(self.module, 4, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
225
247
|
mode = -1
|
|
226
248
|
if r_data[1] & 0b00010000:
|
|
227
|
-
mode =
|
|
249
|
+
mode = 'DC'
|
|
228
250
|
else:
|
|
229
|
-
mode =
|
|
251
|
+
mode = 'AC'
|
|
230
252
|
return (mode)
|
|
231
|
-
|
|
232
|
-
def get_clipped_latched(self):
|
|
233
|
-
# Return:
|
|
234
|
-
# 0 if none clipped
|
|
235
|
-
# 1 if pos clipped
|
|
236
|
-
# 2 if neg clipped
|
|
237
|
-
# 3 if pos and neg clipped (is posible when clipped is latched)
|
|
238
|
-
clipped = -1
|
|
239
|
-
dummy_data = bytearray([0,0])
|
|
240
|
-
r_data = self.spi_rack.read_data(self.module, 7, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
241
|
-
|
|
242
|
-
if (((r_data[0] & 0b01000000) == 0) & ((r_data[0] & 0b10000000) == 0)):
|
|
243
|
-
clipped = 0
|
|
244
|
-
elif (r_data[0] & 0b11000000 == 0b11000000):
|
|
245
|
-
clipped = 3
|
|
246
|
-
elif (r_data[0] & 0b01000000):
|
|
247
|
-
clipped = 2
|
|
248
|
-
elif (r_data[0] & 0b10000000):
|
|
249
|
-
clipped = 1
|
|
250
|
-
|
|
251
|
-
return (clipped)
|
|
252
253
|
|
|
253
254
|
def get_clipped_unlatched(self):
|
|
255
|
+
# Inverted polarity
|
|
254
256
|
# Return:
|
|
255
257
|
# 0 if none clipped
|
|
256
258
|
# 1 if pos clipped
|
|
257
259
|
# 2 if neg clipped
|
|
258
260
|
# 3 if pos and neg clipped (is posible when clipped is latched)
|
|
259
261
|
|
|
260
|
-
clipped =
|
|
262
|
+
clipped = ''
|
|
261
263
|
dummy_data = bytearray([0,0])
|
|
262
|
-
r_data = self.spi_rack.read_data(self.module,
|
|
264
|
+
r_data = self.spi_rack.read_data(self.module, 3, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
263
265
|
|
|
264
266
|
if (r_data[0] & 0b00110000) == 0b00110000:
|
|
265
|
-
clipped =
|
|
267
|
+
clipped = 'not clipped'
|
|
266
268
|
elif (((r_data[0] & 0b00010000) == 0) & ((r_data[0] & 0b00100000) == 0)):
|
|
267
|
-
clipped =
|
|
269
|
+
clipped = 'pos and neg clipped'
|
|
268
270
|
elif (r_data[0] & 0b00010000) == 0:
|
|
269
|
-
clipped =
|
|
271
|
+
clipped = 'pos clipped'
|
|
270
272
|
elif (r_data[0] & 0b00100000) == 0:
|
|
271
|
-
clipped =
|
|
273
|
+
clipped = 'neg clipped'
|
|
274
|
+
|
|
275
|
+
return (clipped)
|
|
276
|
+
|
|
277
|
+
def get_clipped_latched(self):
|
|
278
|
+
# Regular polarity (non-inverted)
|
|
279
|
+
# Return:
|
|
280
|
+
# 0 if none clipped
|
|
281
|
+
# 1 if pos clipped
|
|
282
|
+
# 2 if neg clipped
|
|
283
|
+
# 3 if pos and neg clipped (is posible when clipped is latched)
|
|
284
|
+
clipped = ''
|
|
285
|
+
dummy_data = bytearray([0,0])
|
|
286
|
+
r_data = self.spi_rack.read_data(self.module, 4, BICPINS_MODE, BICPINS_SPEED, dummy_data)
|
|
287
|
+
|
|
288
|
+
if (((r_data[0] & 0b01000000) == 0) & ((r_data[0] & 0b10000000) == 0)):
|
|
289
|
+
clipped = 'not clipped'
|
|
290
|
+
elif (r_data[0] & 0b11000000 == 0b11000000):
|
|
291
|
+
clipped = 'pos and neg clipped'
|
|
292
|
+
elif (r_data[0] & 0b01000000):
|
|
293
|
+
clipped = 'neg clipped'
|
|
294
|
+
elif (r_data[0] & 0b10000000):
|
|
295
|
+
clipped = 'pos clipped'
|
|
272
296
|
|
|
273
297
|
return (clipped)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.2.20'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.2.18'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|