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:
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:
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:
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:
get_sample_amount(ADC)
Gets the amount of samples that the ADC channel takes per trigger.
Parameters:
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:
get_ADC_enable(ADC)
Gets the status of the ADC channel: if it is enabled or not.
Parameters:
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:
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:
get_filter_rate(ADC)
Returns the ADC filter setting of the given ADC. See the filter table to interpret the result.
Parameters:
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:
get_filter_type(ADC)
Returns the filter type of the given ADC.
Parameters:
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:
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:
Returns - the sample rate in seconds (float)