def test_fetch_history_ram_cycle_information_position_out_of_bound(self): self.patched_library.niDigital_GetHistoryRAMSampleCount.side_effect = self.side_effects_helper.niDigital_GetHistoryRAMSampleCount self.side_effects_helper['GetHistoryRAMSampleCount']['sampleCount'] = 7 with nidigital.Session('') as session: with pytest.raises(ValueError, match='position: Specified value = 8, Maximum value = 6.'): session.sites[1].fetch_history_ram_cycle_information(position=8, samples_to_read=-1)
def test_fetch_history_ram_cycle_information_pin_list(self): self.patched_library.niDigital_GetHistoryRAMSampleCount.side_effect = self.side_effects_helper.niDigital_GetHistoryRAMSampleCount self.side_effects_helper['GetHistoryRAMSampleCount']['sampleCount'] = 1 self.patched_library.niDigital_GetAttributeViBoolean.side_effect = self.side_effects_helper.niDigital_GetAttributeViBoolean self.side_effects_helper['GetAttributeViBoolean'][ 'value'] = True # history_ram_number_of_samples_is_finite self.patched_library.niDigital_FetchHistoryRAMCycleInformation.side_effect = self.side_effects_helper.niDigital_FetchHistoryRAMCycleInformation self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'patternIndex'] = 0 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'timeSetIndex'] = 0 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'vectorNumber'] = 0 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'cycleNumber'] = 0 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'numDutCycles'] = 1 self.patched_library.niDigital_GetPatternName.side_effect = self.side_effects_helper.niDigital_GetPatternName self.side_effects_helper['GetPatternName']['name'] = 'new_pattern' self.patched_library.niDigital_GetTimeSetName.side_effect = self.side_effects_helper.niDigital_GetTimeSetName self.side_effects_helper['GetTimeSetName']['name'] = 't0' self.patched_library.niDigital_FetchHistoryRAMScanCycleNumber.side_effect = self.side_effects_helper.niDigital_FetchHistoryRAMScanCycleNumber self.side_effects_helper['FetchHistoryRAMScanCycleNumber'][ 'scanCycleNumber'] = -1 self.patched_library.niDigital_FetchHistoryRAMCyclePinData.side_effect = self.niDigital_FetchHistoryRAMCyclePinData_check_pins_looping with nidigital.Session('') as session: self.expected_pin_list_check_pins_looping = 'PinA,PinB' session.sites[0].pins['PinA', 'PinB'].fetch_history_ram_cycle_information( position=0, samples_to_read=-1) self.expected_pin_list_check_pins_looping = '' session.sites[0].fetch_history_ram_cycle_information( position=0, samples_to_read=-1) assert self.patched_library.niDigital_FetchHistoryRAMCyclePinData.call_count == 4
def test_fetch_history_ram_cycle_information_samples_to_read_all(self): self.patched_library.niDigital_GetHistoryRAMSampleCount.side_effect = self.side_effects_helper.niDigital_GetHistoryRAMSampleCount self.side_effects_helper['GetHistoryRAMSampleCount']['sampleCount'] = 7 self.patched_library.niDigital_GetAttributeViBoolean.side_effect = self.side_effects_helper.niDigital_GetAttributeViBoolean self.side_effects_helper['GetAttributeViBoolean']['value'] = True # history_ram_number_of_samples_is_finite self.patched_library.niDigital_FetchHistoryRAMCycleInformation.side_effect = self.niDigital_FetchHistoryRAMCycleInformation_looping self.patched_library.niDigital_GetPatternName.side_effect = self.side_effects_helper.niDigital_GetPatternName self.side_effects_helper['GetPatternName']['name'] = 'new_pattern' self.patched_library.niDigital_GetTimeSetName.side_effect = self.niDigital_GetTimeSetName_looping self.patched_library.niDigital_FetchHistoryRAMScanCycleNumber.side_effect = self.niDigital_FetchHistoryRAMScanCycleNumber_looping self.patched_library.niDigital_FetchHistoryRAMCyclePinData.side_effect = self.niDigital_FetchHistoryRAMCyclePinData_looping self.patched_library.niDigital_GetPatternPinList.side_effect = self.side_effects_helper.niDigital_GetPatternPinList pin_list = ['LO' + str(i) for i in range(4)] + ['HI' + str(i) for i in range(4)] self.side_effects_helper['GetPatternPinList']['pinList'] = ','.join(pin_list) with nidigital.Session('') as session: history_ram_cycle_info = session.sites[1].fetch_history_ram_cycle_information( position=0, samples_to_read=-1) assert self.patched_library.niDigital_FetchHistoryRAMCycleInformation.call_count == 7 assert self.patched_library.niDigital_GetPatternName.call_count == 2 # there's only one pattern, so this is a 2 assert self.patched_library.niDigital_GetTimeSetName.call_count == 6 # 3 time sets, so this is a 6 assert self.patched_library.niDigital_FetchHistoryRAMScanCycleNumber.call_count == 7 assert self.patched_library.niDigital_FetchHistoryRAMCyclePinData.call_count == 20 # 10 DUT cycles assert len(history_ram_cycle_info) == 7 assert all([i.pattern_name == 'new_pattern' for i in history_ram_cycle_info]) time_set_names = [i.time_set_name for i in history_ram_cycle_info] assert time_set_names == ['t0', 'tScan', 'tScan', 't2X', 't2X', 't2X', 't0'] vector_numbers = [i.vector_number for i in history_ram_cycle_info] assert vector_numbers == [5, 6, 6, 7, 7, 8, 9] cycle_numbers = [i.cycle_number for i in history_ram_cycle_info] assert cycle_numbers == list(range(5, 12)) scan_cycle_numbers = [i.scan_cycle_number for i in history_ram_cycle_info] assert scan_cycle_numbers == [-1, 0, 1, -1, -1, -1, -1] pin_names = session.get_pattern_pin_names('new_pattern') assert self.patched_library.niDigital_GetPatternPinList.call_count == 2 assert pin_names == pin_list expected_pin_states = [i.expected_pin_states for i in history_ram_cycle_info] assert expected_pin_states == self.expected_pin_states_looping # If test expects actual pin state to be 'X', then value returned by the API can be anything. # So, need to skip those pin states while comparing. actual_pin_states = [i.actual_pin_states for i in history_ram_cycle_info] assert len(actual_pin_states) == len(self.actual_pin_states_looping) for vector_pin_states, vector_pin_states_expected_by_test in zip(actual_pin_states, self.actual_pin_states_looping): for cycle_pin_states, cycle_pin_states_expected_by_test in zip(vector_pin_states, vector_pin_states_expected_by_test): for pin_state, pin_state_expected_by_test in zip(cycle_pin_states, cycle_pin_states_expected_by_test): if pin_state_expected_by_test is not nidigital.PinState.X: assert pin_state == pin_state_expected_by_test # Only the first cycle returned is expected to have failures per_pin_pass_fail = [i.per_pin_pass_fail for i in history_ram_cycle_info] assert per_pin_pass_fail == self.per_pin_pass_fail_looping
def test_fetch_history_ram_cycle_information_site_n(self): self.patched_library.niDigital_GetHistoryRAMSampleCount.side_effect = self.niDigital_GetHistoryRAMSampleCount_check_site_looping self.side_effects_helper['GetHistoryRAMSampleCount']['sampleCount'] = 1 with nidigital.Session('') as session: for s in self.site_numbers_looping: session.sites[s].fetch_history_ram_cycle_information(position=0, samples_to_read=0) assert self.patched_library.niDigital_GetHistoryRAMSampleCount.call_count == len(self.site_numbers_looping)
def example(resource_name, options, channels, voltage_config, time_set_config): with nidigital.Session(resource_name=resource_name, options=options) as session: dir = os.path.dirname(__file__) # Load pin map (.pinmap) created using Digital Pattern Editor pin_map_filename = os.path.join(dir, 'PinMap.pinmap') session.load_pin_map(pin_map_filename) # Configure voltage levels and terminal voltage through driver API session.channels[channels].configure_voltage_levels( voltage_config.vil, voltage_config.vih, voltage_config.vol, voltage_config.voh, voltage_config.vterm) if voltage_config.termination_mode == 'High_Z': session.channels[ channels].termination_mode = nidigital.TerminationMode.HIGH_Z elif voltage_config.termination_mode == 'Active_Load': session.channels[ channels].termination_mode = nidigital.TerminationMode.ACTIVE_LOAD session.channels[channels].configure_active_load_levels( voltage_config.iol, voltage_config.ioh, voltage_config.vcom) else: session.channels[ channels].termination_mode = nidigital.TerminationMode.VTERM # Configure time set through driver API session.create_time_set(time_set_config.time_set_name ) # Must match time set name in pattern file session.configure_time_set_period(time_set_config.time_set_name, time_set_config.period) session.channels[channels].configure_time_set_drive_edges( time_set_config.time_set_name, convert_drive_format(time_set_config.drive_format), time_set_config.drive_on, time_set_config.drive_data, time_set_config.drive_return, time_set_config.drive_off) session.channels[channels].configure_time_set_compare_edges_strobe( time_set_config.time_set_name, time_set_config.strobe_edge) # Load the pattern file (.digipat) created using Digital Pattern Editor pattern_filename = os.path.join(dir, 'Pattern.digipat') session.load_pattern(pattern_filename) # Burst pattern, blocks until the pattern is done bursting session.burst_pattern(start_label='new_pattern') print('Start bursting pattern') # Disconnect all channels using programmable onboard switching session.selected_function = nidigital.SelectedFunction.DISCONNECT print('Done bursting pattern')
def test_fetch_history_ram_cycle_information_position_last(self): self.patched_library.niDigital_GetHistoryRAMSampleCount.side_effect = self.side_effects_helper.niDigital_GetHistoryRAMSampleCount self.side_effects_helper['GetHistoryRAMSampleCount']['sampleCount'] = 7 self.patched_library.niDigital_GetAttributeViBoolean.side_effect = self.side_effects_helper.niDigital_GetAttributeViBoolean self.side_effects_helper['GetAttributeViBoolean'][ 'value'] = True # history_ram_number_of_samples_is_finite self.patched_library.niDigital_FetchHistoryRAMCycleInformation.side_effect = self.side_effects_helper.niDigital_FetchHistoryRAMCycleInformation self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'patternIndex'] = 0 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'timeSetIndex'] = 0 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'vectorNumber'] = 9 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'cycleNumber'] = 11 self.side_effects_helper['FetchHistoryRAMCycleInformation'][ 'numDutCycles'] = 1 self.patched_library.niDigital_GetPatternName.side_effect = self.side_effects_helper.niDigital_GetPatternName self.side_effects_helper['GetPatternName']['name'] = 'new_pattern' self.patched_library.niDigital_GetTimeSetName.side_effect = self.side_effects_helper.niDigital_GetTimeSetName self.side_effects_helper['GetTimeSetName']['name'] = 't0' self.patched_library.niDigital_FetchHistoryRAMScanCycleNumber.side_effect = self.side_effects_helper.niDigital_FetchHistoryRAMScanCycleNumber self.side_effects_helper['FetchHistoryRAMScanCycleNumber'][ 'scanCycleNumber'] = -1 self.patched_library.niDigital_FetchHistoryRAMCyclePinData.side_effect = self.side_effects_helper.niDigital_FetchHistoryRAMCyclePinData self.side_effects_helper['FetchHistoryRAMCyclePinData'][ 'actualNumPinData'] = 8 self.side_effects_helper['FetchHistoryRAMCyclePinData'][ 'expectedPinStates'] = [nidigital.enums.PinState.X.value] * 8 self.side_effects_helper['FetchHistoryRAMCyclePinData'][ 'actualPinStates'] = [ nidigital.enums.PinState.NOT_A_PIN_STATE.value ] * 8 self.side_effects_helper['FetchHistoryRAMCyclePinData'][ 'perPinPassFail'] = [True] * 8 with nidigital.Session('') as session: history_ram_cycle_info = session.sites[ 1].fetch_history_ram_cycle_information(position=6, samples_to_read=-1) self.patched_library.niDigital_FetchHistoryRAMCycleInformation.assert_called_once( ) assert self.patched_library.niDigital_GetPatternName.call_count == 2 assert self.patched_library.niDigital_GetTimeSetName.call_count == 2 self.patched_library.niDigital_FetchHistoryRAMScanCycleNumber.assert_called_once( ) assert self.patched_library.niDigital_FetchHistoryRAMCyclePinData.call_count == 2 assert len(history_ram_cycle_info) == 1 assert history_ram_cycle_info[0].vector_number == 9 assert history_ram_cycle_info[0].cycle_number == 11
def test_fetch_history_ram_cycle_information_samples_to_read_too_much(self): self.patched_library.niDigital_GetHistoryRAMSampleCount.side_effect = self.side_effects_helper.niDigital_GetHistoryRAMSampleCount self.side_effects_helper['GetHistoryRAMSampleCount']['sampleCount'] = 7 self.patched_library.niDigital_GetAttributeViBoolean.side_effect = self.side_effects_helper.niDigital_GetAttributeViBoolean self.side_effects_helper['GetAttributeViBoolean']['value'] = True # history_ram_number_of_samples_is_finite with nidigital.Session('') as session: assert session.sites[1].get_history_ram_sample_count() == 7 expected_error_description = ( 'position: Specified value = 3, samples_to_read: Specified value = 5; Samples available = 4.') with pytest.raises(ValueError, match=expected_error_description): session.sites[1].fetch_history_ram_cycle_information(position=3, samples_to_read=5)
def example(resource_name, options, trigger_source=None, trigger_edge=None): with nidigital.Session(resource_name=resource_name, options=options) as session: dir = os.path.join(os.path.dirname(__file__)) # Load the pin map (.pinmap) created using the Digital Pattern Editor pin_map_filename = os.path.join(dir, 'PinMap.pinmap') session.load_pin_map(pin_map_filename) # Load the specifications (.specs), levels (.digilevels), and timing (.digitiming) sheets created using the Digital Pattern Editor spec_filename = os.path.join(dir, 'Specifications.specs') levels_filename = os.path.join(dir, 'PinLevels.digilevels') timing_filename = os.path.join(dir, 'Timing.digitiming') session.load_specifications_levels_and_timing(spec_filename, levels_filename, timing_filename) # Apply the settings from the levels and timing sheets we just loaded to the session session.apply_levels_and_timing(levels_filename, timing_filename) # Loading the pattern file (.digipat) created using the Digital Pattern Editor pattern_filename = os.path.join(dir, 'Pattern.digipat') session.load_pattern(pattern_filename) if trigger_source is None: print('Start bursting pattern') else: # Specify a source and edge for the external start trigger session.start_trigger_type = nidigital.TriggerType.DIGITAL_EDGE session.digital_edge_start_trigger_source = trigger_source session.digital_edge_start_trigger_edge = nidigital.DigitalEdge.RISING if trigger_edge == 'Rising' else nidigital.DigitalEdge.FALLING print('Wait for start trigger and then start bursting pattern') # If start trigger is configured, waiting for the trigger to start bursting and then blocks until the pattern is done bursting # Else just start bursting and block until the pattern is done bursting session.burst_pattern(start_label='new_pattern') # Disconnect all channels using programmable onboard switching session.selected_function = nidigital.SelectedFunction.DISCONNECT print('Done bursting pattern')
def example(resource_name, options, channels, measure, aperture_time, source=None, settling_time=None, current_level_range=None, current_level=None, voltage_limit_high=None, voltage_limit_low=None, current_limit_range=None, voltage_level=None): with nidigital.Session(resource_name=resource_name, options=options) as session: dir = os.path.join(os.path.dirname(__file__)) # Load pin map (.pinmap) created using Digital Pattern Editor pin_map_filename = os.path.join(dir, 'PinMap.pinmap') session.load_pin_map(pin_map_filename) # Configure the PPMU measurement aperture time session.channels[channels].ppmu_aperture_time = aperture_time session.channels[ channels].ppmu_aperture_time_units = nidigital.PPMUApertureTimeUnits.SECONDS # Configure and source if source == 'source-current': session.channels[ channels].ppmu_output_function = nidigital.PPMUOutputFunction.CURRENT session.channels[ channels].ppmu_current_level_range = current_level_range session.channels[channels].ppmu_current_level = current_level session.channels[ channels].ppmu_voltage_limit_high = voltage_limit_high session.channels[ channels].ppmu_voltage_limit_low = voltage_limit_low session.channels[channels].ppmu_source() # Settling time between sourcing and measuring time.sleep(settling_time) elif source == 'source-voltage': session.channels[ channels].ppmu_output_function = nidigital.PPMUOutputFunction.VOLTAGE session.channels[ channels].ppmu_current_limit_range = current_limit_range session.channels[channels].ppmu_voltage_level = voltage_level session.channels[channels].ppmu_source() # Settling time between sourcing and measuring time.sleep(settling_time) pin_info = session.channels[channels].get_pin_results_pin_information() # Measure if measure == 'current': current_measurements = session.channels[channels].ppmu_measure( nidigital.PPMUMeasurementType.CURRENT) print('{:<6} {:<20} {:<10}'.format('Site', 'Pin Name', 'Current')) for pin, current in zip(pin_info, current_measurements): print('{:<6d} {:<20} {:<10f}'.format(pin.site_number, pin.pin_name, current)) else: voltage_measurements = session.channels[channels].ppmu_measure( nidigital.PPMUMeasurementType.VOLTAGE) print('{:<6} {:<20} {:<10}'.format('Site', 'Pin Name', 'Voltage')) for pin, voltage in zip(pin_info, voltage_measurements): print('{:<6d} {:<20} {:<10f}'.format(pin.site_number, pin.pin_name, voltage)) # Disconnect all channels using programmable onboard switching session.channels[ channels].selected_function = nidigital.SelectedFunction.DISCONNECT
from os import path import nidigital from nimipi import rffe from rfmd8090 import Rfmd8090 digital_project_path = path.abspath(r"nimipi\digiproj") pin_map_file_path = path.join(digital_project_path, "PinMap.pinmap") specifications_file_path = path.join(digital_project_path, "Specifications.specs") levels_file_path = path.join(digital_project_path, "PinLevels.digilevels") timing_file_path = path.join(digital_project_path, "Timing.digitiming") pattern_directory_path = path.join(digital_project_path, "RFFE Command Patterns") digital = nidigital.Session("PXIe-6570", True, False) rffe.load_pin_map(digital, pin_map_file_path) rffe.load_sheets(digital, specifications_file_path, levels_file_path, timing_file_path) rffe.load_patterns(digital, pattern_directory_path) digital.channels["RFFEVIO"].ppmu_configure_output_function(nidigital.PPMUOutputFunction.VOLTAGE.value) digital.channels["RFFEVIO"].ppmu_configure_voltage_level(1.8) digital.channels["RFFEVIO"].ppmu_configure_current_limit_range(0.032) digital.channels["RFFEVIO"].ppmu_source() multi_command_write = Rfmd8090.Band1Apt multi_command_read = Rfmd8090.Band1Apt multi_read_data = rffe.multi_command(digital, "RFFEDATA", multi_command_write, multi_command_read) for register_data in multi_command_write: print("Slave: 0x{:02X}".format(register_data.slave_address) + \ " | Register: 0x{:02X}".format(register_data.register_address) + \ " | WriteData: " + ", ".join(map("0x{:02X}".format, register_data.write_data)))
def multi_instrument_session(): with nidigital.Session( resource_name=','.join(instr), options='Simulate=1, DriverSetup=Model:6570') as simulated_session: yield simulated_session
""" Overview This getting started example demonstrates how to use the NI-Digital Pattern Driver API to load pre-created files with SPI pattern information on the NI Digital Pattern Instrument, burst the pattern, and record the site pass/fail information. """ import nidigital levels_sheet = 'PinLevels.digilevels' timing_sheet = 'Timing.digitiming' session = nidigital.Session("PXI1Slot2,PXI1Slot3", False, False, { "Simulate": True, "DriverSetup": { "Model": "6570" } }) # Load the pin map for the instrument at the beginning of the test program to reference pin names the pin map defines. session.load_pin_map("PinMap.pinmap") # Load the specifications, levels, and timing files you created in the Digital Pattern Editor on the instrument. # # These settings are not applied until you call the apply_levels_and_timing. session.load_specifications_levels_and_timing('Specifications.specs', levels_sheet, timing_sheet) # Apply the settings from the levels and timing files you just loaded on the instrument. session.apply_levels_and_timing(levels_sheet, timing_sheet) # Load the pattern file (.digipat) you created in the Digital Pattern Editor on the instrument.