spirack 0.2.10__tar.gz → 0.2.14__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.
Files changed (33) hide show
  1. {spirack-0.2.10 → spirack-0.2.14}/PKG-INFO +1 -1
  2. {spirack-0.2.10 → spirack-0.2.14}/spirack/D4a_module.py +13 -5
  3. {spirack-0.2.10 → spirack-0.2.14}/spirack/D5a_module.py +47 -16
  4. spirack-0.2.14/spirack/S5k_module.py +858 -0
  5. spirack-0.2.14/spirack/version.py +1 -0
  6. {spirack-0.2.10 → spirack-0.2.14}/spirack.egg-info/PKG-INFO +1 -1
  7. spirack-0.2.10/spirack/S5k_module.py +0 -558
  8. spirack-0.2.10/spirack/version.py +0 -1
  9. {spirack-0.2.10 → spirack-0.2.14}/LICENSE +0 -0
  10. {spirack-0.2.10 → spirack-0.2.14}/README.md +0 -0
  11. {spirack-0.2.10 → spirack-0.2.14}/setup.cfg +0 -0
  12. {spirack-0.2.10 → spirack-0.2.14}/setup.py +0 -0
  13. {spirack-0.2.10 → spirack-0.2.14}/spirack/B1b_module.py +0 -0
  14. {spirack-0.2.10 → spirack-0.2.14}/spirack/B2b_module.py +0 -0
  15. {spirack-0.2.10 → spirack-0.2.14}/spirack/D4_module.py +0 -0
  16. {spirack-0.2.10 → spirack-0.2.14}/spirack/D4b_module.py +0 -0
  17. {spirack-0.2.10 → spirack-0.2.14}/spirack/D5b_module.py +0 -0
  18. {spirack-0.2.10 → spirack-0.2.14}/spirack/F1d_module.py +0 -0
  19. {spirack-0.2.10 → spirack-0.2.14}/spirack/M2j_module.py +0 -0
  20. {spirack-0.2.10 → spirack-0.2.14}/spirack/M2p_module.py +0 -0
  21. {spirack-0.2.10 → spirack-0.2.14}/spirack/P2d_module.py +0 -0
  22. {spirack-0.2.10 → spirack-0.2.14}/spirack/S4g_module.py +0 -0
  23. {spirack-0.2.10 → spirack-0.2.14}/spirack/S5i_module.py +0 -0
  24. {spirack-0.2.10 → spirack-0.2.14}/spirack/S5l_module.py +0 -0
  25. {spirack-0.2.10 → spirack-0.2.14}/spirack/U1c_module.py +0 -0
  26. {spirack-0.2.10 → spirack-0.2.14}/spirack/U2_module.py +0 -0
  27. {spirack-0.2.10 → spirack-0.2.14}/spirack/__init__.py +0 -0
  28. {spirack-0.2.10 → spirack-0.2.14}/spirack/chip_mode.py +0 -0
  29. {spirack-0.2.10 → spirack-0.2.14}/spirack/spi_rack.py +0 -0
  30. {spirack-0.2.10 → spirack-0.2.14}/spirack.egg-info/SOURCES.txt +0 -0
  31. {spirack-0.2.10 → spirack-0.2.14}/spirack.egg-info/dependency_links.txt +0 -0
  32. {spirack-0.2.10 → spirack-0.2.14}/spirack.egg-info/requires.txt +0 -0
  33. {spirack-0.2.10 → spirack-0.2.14}/spirack.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spirack
3
- Version: 0.2.10
3
+ Version: 0.2.14
4
4
  Summary: Drivers for the QuTech SPI-rack
5
5
  Home-page: https://github.com/mtiggelman/SPI-rack
6
6
  Author: Marijn Tiggelman
@@ -42,7 +42,7 @@ class D4a_module(object):
42
42
  module (int): module number set on the hardware
43
43
  """
44
44
  self.file = os.path.abspath(__file__)
45
- print("D4a initialized.\nFile path is", self.file,"\n") # debug only
45
+ print("D4a initialized.\nPath to D4a file is", self.file,"\n") # debug only
46
46
 
47
47
  self.module = module
48
48
  self.spi_rack = spi_rack
@@ -89,6 +89,7 @@ class D4a_module(object):
89
89
  self.config_led(adc, 0)
90
90
 
91
91
  self.SR_OEb = 0 # initializing the SR output_enable\ to 'enabled'
92
+ self.set_output_enable(self.SR_OEb)
92
93
 
93
94
  def continuous_conversion_trig_and_read(self, adc):
94
95
  """Perform a conversion
@@ -165,11 +166,18 @@ class D4a_module(object):
165
166
  """
166
167
  running = True
167
168
  while running:
168
- status = self._read_data(adc, self.reg.STATUS_REG, 1)
169
+ status = self._read_RDYb_bit(adc)
169
170
  # if new data available:
170
- if (status[0]&0x80) == 0:
171
+ if status == 0:
171
172
  running = False
172
173
  return
174
+
175
+ def _read_RDYb_bit(self, adc):
176
+ """reads out the RDYb bit from the specified ADC
177
+ """
178
+ status = self._read_data(adc, self.reg.STATUS_REG, 1)
179
+ RDYb = status[0]&0x80
180
+ return RDYb
173
181
 
174
182
  def force_immediate_read_out(self, adc):
175
183
  """Reads the ADC data output register, regardless of its RDY/complete status
@@ -970,13 +978,13 @@ class D4a_module(object):
970
978
  if user_sync_value not in range(0, 2):
971
979
  raise ValueError('The sync_value given {} is not a legal value. Possible values are in {}'.format(user_sync_value, range(0, 2)))
972
980
 
973
- print("sync_signal from user is ",bytearray([user_sync_value]))
981
+ print("set_sync_signal:\n sync_signal from user is ",bytearray([user_sync_value]))
974
982
 
975
983
  # The output byte holds two bits:
976
984
  # The 'SR_OEb' - the existing SR_OEb kept in memory
977
985
  # The trig/sync - the new user_sync_value given here explicitly by the user
978
986
  output_byte = self.SR_OEb<<7|user_sync_value
979
- print("The output_byte from BIC to module is",output_byte)
987
+ print(" The output_byte from BIC to module is",output_byte)
980
988
 
981
989
  # Write to SPI addr 5 - the GPIO output direction
982
990
  self.spi_rack.write_data(self.module, 5, 0, BICPINS_SPEED, bytearray([output_byte]))
@@ -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,8 +67,8 @@ 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.span = [np.nan]*self._num_dacs
71
- self.voltages = [np.nan]*self._num_dacs
70
+ self.span = [np.NaN]*self._num_dacs
71
+ self.voltages = [np.NaN]*self._num_dacs
72
72
 
73
73
  for i in range(self._num_dacs):
74
74
  self.get_settings(i)
@@ -126,6 +126,11 @@ class D5a_module(object):
126
126
  DAC_ic = DAC//2
127
127
  # send data via controller
128
128
  self.spi_rack.write_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_SPEED, data)
129
+
130
+ # The change of span will also cause a change in the actual output voltage
131
+ # Make update to the voltages array to reflect that change
132
+ new_settings = self.get_settings(DAC) # read from actual hardware
133
+ self.span[DAC] = new_settings[0] # update to the cached variables
129
134
 
130
135
  def change_span(self, DAC, span):
131
136
  """Changes the software span of selected DAC without update
@@ -249,6 +254,34 @@ class D5a_module(object):
249
254
  # send data via controller
250
255
  self.spi_rack.write_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_SPEED, data)
251
256
 
257
+ def update_multiple_this_is_a_test(self, DAC1, DAC2):
258
+ """Updates the output of the DAC to the written value
259
+
260
+ Updates the output of the DAC when called. Neccessary after using
261
+ change_value or change_span when wanting to update the DAC.
262
+
263
+ Args:
264
+ DAC (int: 0-15): DAC inside the module of which to update
265
+ """
266
+ if DAC not in range(self._num_dacs):
267
+ raise ValueError('D5a module {} [update]: DAC {} does not exist.'.format(self.module, DAC))
268
+
269
+ # Determine which DAC in IC by checking even/uneven
270
+ address = (DAC%2)<<1
271
+
272
+ # Update DAC to given span/value
273
+ command = 0b0100
274
+ b1 = (command<<4) | address
275
+ b2 = 0
276
+ b3 = 0
277
+ b4 = 0
278
+ data = bytearray([b1, b2, b3, b4])
279
+
280
+ # Determine in which IC the DAC is, for SPI chip select
281
+ DAC_ic = DAC//2
282
+ # send data via controller
283
+ self.spi_rack.write_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_SPEED, data)
284
+
252
285
  def set_voltage(self, DAC, voltage):
253
286
  """Sets the DAC output voltage and updates the DAC output
254
287
 
@@ -313,7 +346,7 @@ class D5a_module(object):
313
346
  def get_stepsize(self, DAC):
314
347
  """Returns the smallest voltage step for a given DAC
315
348
 
316
- Calculates and returns the smallest voltage step of the DAC for the
349
+ Calculates and returns the smalles voltage step of the DAC for the
317
350
  set span. Voltage steps smaller than this will not change the DAC value.
318
351
  Recommended to only step the DAC in multiples of this value, as otherwise
319
352
  steps might not behave as expected.
@@ -327,15 +360,13 @@ class D5a_module(object):
327
360
  raise ValueError('D5a module {} [get_stepsize]: DAC {} does not exist.'.format(self.module, DAC))
328
361
 
329
362
  if self.span[DAC] == D5a_module.range_4V_uni:
330
- return 4.0 / (2 ** 18)
331
- elif self.span[DAC] == D5a_module.range_4V_bi or self.span[DAC] == D5a_module.range_8V_uni:
332
- return 8.0 / (2 ** 18)
333
- elif self.span[DAC] == D5a_module.range_8V_bi:
334
- return 16.0 / (2 ** 18)
335
- elif self.span[DAC] == D5a_module.range_2V_bi:
336
- return 4.0 / (2 ** 18)
337
- else:
338
- raise ValueError(f"Span for DAC {DAC} not set to valid value. Span currently set to {self.span[DAC]}.")
363
+ return 4.0/(2**18)
364
+ if self.span[DAC] == (D5a_module.range_4V_bi or D5a_module.range_8V_uni):
365
+ return 8.0/(2**18)
366
+ if self.span[DAC] == D5a_module.range_8V_bi:
367
+ return 16.0/(2**18)
368
+ if self.span[DAC] == D5a_module.range_2V_bi:
369
+ return 4.0/(2**18)
339
370
 
340
371
  def get_settings(self, DAC):
341
372
  """Reads current DAC settings
@@ -357,14 +388,14 @@ class D5a_module(object):
357
388
  DAC_ic = DAC//2
358
389
 
359
390
  # Read code command
360
- command = 0b1101
391
+ command = 0b1101 # 0xd
361
392
  data = bytearray([(command<<4) | address, 0, 0, 0])
362
393
 
363
394
  code_data = self.spi_rack.read_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_RD_SPEED, data)
364
395
  code = (code_data[1]<<10) | (code_data[2]<<2) | (code_data[3]>>6)
365
396
 
366
397
  # Read span command
367
- command = 0b1100
398
+ command = 0b1100 # 0xc
368
399
  data = bytearray([(command<<4) | address, 0, 0, 0])
369
400
 
370
401
  span_data = self.spi_rack.read_data(self.module, DAC_ic, LTC2758_MODE, LTC2758_RD_SPEED, data)
@@ -385,5 +416,5 @@ class D5a_module(object):
385
416
 
386
417
  self.voltages[DAC] = voltage
387
418
  self.span[DAC] = span
388
-
419
+
389
420
  return [voltage, span]