S4g_module


class spirack.S4g_module(spi_rack, module, reset_currents=True)

S4g module interface class. This class does the low level interfacing with the S4g module. When creating an instance it requires a SPI_rack class passed as a parameter. The analog span of the DAC module can be set via software for each of the 4 DACs/current sources.

Setting the current can happen via the set_current function. Other ways are the change_value_update function, which immediately updates the output of the DAC, or via the change_value function. This function writes the new value to the DAC but does not update the output until the update function is ran.

Parameters:

  • spi_rack (SPI_rack) - SPI_rack class object via which the communication runs
  • module (int) - module number set on the harware
  • reset_currents (bool) - if True, then reset all currents to zero and change the span to range_50mA_bi

Methods

set_current(DAC, current)

Sets the output current and updates the DAC output. The function calculates the DAC value for given current at the set span of the DAC. It will set to max/min when input current exceeds span and prints out a warning to the user. There will always be a difference between the set current and the desired output current, as long as not a multiple of the step size is used. The calculated value is floored, not rounded.

Parameters:

  • DAC (int: 0-3) - DAC inside the module of which the current needs to be changed
  • voltage (float) - new DAC current

get_stepsize(DAC)

Returns the smallest current step for a given DAC. The function calculates and returns the smallest current step of the DAC for the set span. Current steps smaller than this will not change the DAC value. Recommended to only step the DAC in multiples of this value, as otherwise steps might not behave as expected.

Parameters:

  • DAC (int: 0-3) - Current output of which the stepsize is calculated

Returns - smallest current step possible with the DAC in its current setting (float)


get_settings(DAC)

Reads current DAC settings. This function reads back the DAC registers of the given DAC for both the code and the span. It calculates the current set with the read out span.

Parameters:

  • DAC (int: 0-15) - DAC inside the module of which the settings will be read

Returns - list with current (float) and span (int): [current, span]


change_span_update(DAC, span)

Changes the span of the DAC and immediately updates the output of the DAC. Use the constants listed below as argument for the span.

Parameters:

  • DAC (int: 0-3) - DAC inside the module of which the span needs to be changed
  • span (int) - values for the span as mentioned in the datasheet, use constants as defined below

change_span(DAC, span)

Changes the span of the DAC without updating the output of the DAC. Only updates when update(DAC) is called. Use the constants listed below as argument for the span.

Parameters:

  • DAC (int: 0-3) - DAC inside the module of which the span needs to be changed
  • span (int) - values for the span as mentioned in the datasheet, use constants as defined below

change_value_update(DAC, value)

Changes the DAC value, where value is an 18-bit integer. Calling this function changes the value of the DAC and immediately updates the output.

Parameters:

  • DAC (int: 0-15) - DAC inside the module of which the value needs to be changed
  • value (18-bit unsigned int) - new DAC value

change_value(DAC, value)

Changes the DAC value, where value is an 18-bit integer. Calling this function changes the value of the DAC, but does not update the output until the update(DAC) function is called.

Parameters:

  • DAC (int: 0-15) - DAC inside the module of which the value needs to be changed
  • value (18-bit unsigned int) - new DAC value

update(DAC)

Updates the output of the DAC to the set range or output value. This is necessary after using change_value or change_span. These functions write into a double buffer inside the chip, when this function is called it will be put into the output buffer.

Parameters:

  • DAC (int: 0-3) - DAC inside the module which needs to be updated

Attributes

Attribute Info
module the module number set by the user (must coincide with hardware)
span a list of values of the span for each DAC in the module
currents a list of DAC current settings last written to the DACs

Constants

Constants
range_50mA_uni
range_50mA_bi
range_25mA_bi