SPI Rack driver
In this tutorial we explain basic usage of the modular SPI Rack drivers provided by the Qblox instruments package. The driver is based on the programming interface provided by SPI-rack.
In order to connect to the SPI Rack driver:
[1]:
from spi_rack.spi_rack import spi_rack
# In our case the SPI Rack is connected to COM port 4
spi = spi_rack('SPI Rack', 'COM4')
Connected to: Qblox SPI Rack (serial:None, firmware:{'device': 'v1.6 - May 10 2019 - mt', 'driver': {'version': '0.3.2', 'date': '21/04/2021-16:38:33', 'hash': '0x94E811E5', 'dirty': False}}) in 0.00s
To verify everything is working correctly we can read out the temperature of the C1b module
[2]:
spi.temperature()
[2]:
23.75
Connecting to S4g
Next, we need to add the modules to our driver. We will be using a S4g module for this tutorial.
[3]:
spi.add_spi_module(2, "S4g")
The S4g module we added can now be accessed through spi.module2
. Let’s try setting an output current:
[4]:
spi.module2.dac0.current(1e-3)
This sets the output current of dac0 (output 1) to 1 mA. We can read this current back through:
[5]:
spi.module2.dac0.current()
[5]:
0.0009998321533203139
Now we will change the output range.
[6]:
spi.module2.dac1.span()
[6]:
'range_max_bi'
We see that the span of DAC channel 1 is set to the default 'range_max_bi'
(corresponding to -40 to +40 mA), changing this works similar to how we change the current.
[7]:
spi.module2.dac1.span('range_min_bi')
spi.module2.dac1.span()
[7]:
'range_min_bi'
Now we updated the range to the smaller -20 to +20 mA range. We will now set all output values back to zero using the convenient set_dacs_zero
function.
[8]:
spi.module2.dac0.current()
[8]:
0.0009998321533203139
[9]:
spi.set_dacs_zero()
[10]:
spi.module2.dac0.current()
[10]:
0.0
Connecting to D5a
Connecting to the D5a module works the same way as the S4g. Instead of the default name module1, let’s give this D5a an alias and call it alice
[11]:
spi.add_spi_module(1, "D5a", "alice")
[12]:
spi.alice.dac0.voltage(1.0)
spi.alice.dac0.voltage()
[12]:
1.0
[13]:
spi.set_dacs_zero()
spi.alice.dac0.voltage()
[13]:
0.0
Similar to the S4g, the D5a also has a span that can be set.
Supported settings are: 'range_4V_uni'
, 'range_4V_bi'
and 'range_2V_bi'
.
[14]:
spi.alice.dac0.span()
[14]:
'range_4V_bi'
Extending the SPI module drivers
It is possible to use custom drivers for the SPI modules within the SPI rack driver provided by qblox-instruments
. Any class that inherits from spi_module_base
is accepted by the spi rack driver. The driver can be added as a module by passing a reference to the class instead of the usual string.
As an example, we will add the dummy_spi_module
to the spi_rack.
[15]:
from spi_rack.spi_module_base import dummy_spi_module
spi.add_spi_module(3, dummy_spi_module, "bob")
Closing the instrument
Finally, we will close the connection to the instrument.
[16]:
spi.close()