B2b_module


class spirack.B2b_module(spi_rack, module, calibrate=False)

SPI Rack interface code for the B2b ADC module: a 2 channel 24-bit ADC module with integrated ARM Cortex M4 microcontroller. It is used to connect to two neighbouring IVVI rack measurement modules. In hardware it is identical to the D4b module, the only difference being the absence of connectors on the front of the module. In contrast to the D4a module, a microcontroller in the module handles all the communication with the ADCs. This allows for exactly timed ADC updates: based on triggers, timers etc.

Parameters:

  • spi_rack (SPI_rack) - SPI_rack class object via which the communication runs
  • module (int) - module number set in hardware
  • calibrate (bool) - if True, runs calibration at initialisation. It will stall the code until the calibration is finished. This takes about 2 seconds.

Methods

set_clock_source(source)

Set the microcontroller clock source to either a local (inside the module) clock or a clock from the backplane. This allows for multiple modules to run of the same clock. The module expects a 10 MHz clock, either sine wave or square.

Parameters:

  • source (string) - either ‘internal’ or ‘external’. Clock source for the microcontroller

get_clock_source()

Gets the set clock source from the microcontroller.

Returns - the set clock source: ‘internal’ or ‘external’ (string)


calibrate()

This will run a gain and offset calibration routine on the B2b module. The function will stall until the routine is finished, which takes about 2 seconds.


is_running()

This function return true if the module is running a measurement, should be used to check if data can be read.

Returns - True if the module is running a measurement


set_trigger_amount(trigger_amount)

Sets the amount of triggers expected.

Parameters:

  • trigger_amount - (int) - amount of triggers

get_trigger_amount()

Gets the amount of triggers expected.

Returns - amount of triggers (int)


set_sample_amount(ADC, sample_amount)

Sets the amount of samples that the ADC channel takes per trigger.

Parameters:

  • ADC (int: 0-1) - ADC inside the module of which to change the sample amount
  • sample_amount - (int) - amount of samples per trigger

get_sample_amount(ADC)

Gets the amount of samples that the ADC channel takes per trigger.

Parameters:

  • ADC (int: 0-1) - ADC inside the module of which to get the sample amount

Returns - amount of samples per trigger for the given ADC (int)


get_firmware_version()

Gets the firmware version of the module

Returns - firmware version of the module (int)


set_ADC_enable(ADC, enable)

Enables given ADC channel

Parameters:

  • ADC (int: 0-1) - ADC channel to activate

get_ADC_enable(ADC)

Gets the status of the ADC channel: if it is enabled or not.

Parameters:

  • ADC (int: 0-1) - ADC channel of which to get status

Returns - the enabled status of the given ADC channel


software_trigger()

Sends a software trigger to the ADC module to take the amount of samples specified by set_sample_amount. This can be used for example to take standalone measurements or to take an FFT measurement.


get_data()

Reads back all the data from the module.

Returns - ADC0, ADC1: numpy arrays of float. None if ADC is not enabled.


cancel()

When this function is called, it cancels the current run of the module. This can be useful if the toggle amount and/or the toggle time are set wrong and long. If the run gets cancelled, the status gets updated to reflect this.


reset()

Resets the module to the IDLE state. This should be called after all the data has been read.


set_trigger_holdoff_time(holdoff_time)

Sets the time the system waits after the trigger with a resolution of 100ns.

Parameters:

  • holdoff_time (seconds) (float) - amount of time to wait after a trigger

get_trigger_holdoff_time()

See ‘set_trigger_holdoff_time’ for details.

Returns - The set holdoff_time in seconds.


set_filter_rate(ADC, filter_rate)

The filter rate (together with the filter type) determines the cutoff frequency, sample rate, the resolution and the 50 Hz rejection. See the filter table to determine which setting to use.

Parameters:

  • ADC (int: 0-1) - ADC channel of which to set the filter rate
  • filter_rate (int:0-20) - the desired filter setting

get_filter_rate(ADC)

Returns the ADC filter setting of the given ADC. See the filter table to interpret the result.

Parameters:

  • ADC (int: 0-1) - ADC channel of which to get the filter rate

Returns - the current filter setting (int)


set_filter_type(ADC, filter_type)

The ADC filter can be set to two different types: ‘sinc3’ or ‘sinc5’. The filter type determines (with the filter rate) the cutoff frequency, sample rate, the resolution and the 50 Hz rejection. See the filter table to determine which setting is correct for your application.

Parameters:

  • ADC (int: 0-1) - ADC channel of which to set the filter type
  • filter_type (string) - possible values are ‘sinc3’ or ‘sinc5’

get_filter_type(ADC)

Returns the filter type of the given ADC.

Parameters:

  • ADC (int: 0-1) - ADC channel of which to get the filter type

Returns - the current filter type (string)


set_trigger_input(trigger)

Sets the trigger input location for the ADC module. If it is set to ‘None’, no external triggers will start the module: it will only start via the software_trigger function. Otherwise it will trigger on rising edges from either the controller module or the D5b.

Parameters:

  • trigger (string) - the input location. Pssible values are: None, Controller, D5b

get_trigger_input(ADC)

Gets the trigger input location

Returns - the currently set trigger input location (string)


get_sample_time(ADC)

Gives the sample rate in seconds of the ADC. This corresponds to the values in the filter table. These values can be used for plotting or a FFT calculation.

Parameters:

  • ADC (int: 0-1) - ADC of which to get the sample time

Returns - the sample rate in seconds (float)