niscope module¶
Installation¶
As a prerequisite to using the niscope module, you must install the NI-SCOPE runtime on your system. Visit ni.com/downloads to download the driver runtime for your devices.
The nimi-python modules (i.e. for NI-SCOPE) can be installed with pip:
$ python -m pip install niscope
Or easy_install from setuptools:
$ python -m easy_install niscope
Usage¶
The following is a basic example of using the niscope module to open a session to a High Speed Digitizer and capture a single record of 1000 points.
import niscope
with niscope.Session("Dev1") as session:
session.channels[0].configure_vertical(range=1.0, coupling=niscope.VerticalCoupling.AC)
session.channels[1].configure_vertical(range=10.0, coupling=niscope.VerticalCoupling.DC)
session.configure_horizontal_timing(min_sample_rate=50000000, min_num_pts=1000, ref_position=50.0, num_records=5, enforce_realtime=True)
with session.initiate():
waveforms = session.channels[0,1].fetch(num_records=5)
for wfm in waveforms:
print('Channel {0}, record {1} samples acquired: {2:,}\n'.format(wfm.channel, wfm.record, len(wfm.samples)))
# Find all channel 1 records (Note channel name is always a string even if integers used in channel[])
chan1 = [wfm for wfm in waveforms if wfm.channel == '0']
# Find all record number 3
rec3 = [wfm for wfm in waveforms if wfm.record == 3]
The waveform returned from fetch is a flat list of Python objects
Attributes:
relative_initial_x (float) the time (in seconds) from the trigger to the first sample in the fetched waveform
absolute_initial_x (float) timestamp (in seconds) of the first fetched sample. This timestamp is comparable between records and acquisitions; devices that do not support this parameter use 0 for this output.
x_increment (float) the time between points in the acquired waveform in seconds
channel (str) channel name this waveform was acquired from
record (int) record number of this waveform
gain (float) the gain factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
offset (float) the offset factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
samples (array of float) floating point array of samples. Length will be of the actual samples acquired
Such that all record 0 waveforms are first. For example, with a channel list of 0,1, you would have the following index values:
- index 0 = record 0, channel 0
- index 1 = record 0, channel 1
- index 2 = record 1, channel 0
- index 3 = record 1, channel 1
- etc.
If you need more performance or need to work with SciPy, you can use the fetch_into() method instead of fetch(). This method takes an already allocated numpy array and puts the acquired samples in it. Data types supported:
- numpy.float64
- numpy.int8
- numpy.in16
- numpy.int32
voltage_range = 1.0
record_length = 2000
channels = [0, 1]
num_channels = len(channels)
num_records = 5
wfm = numpy.ndarray(num_channels * record_length, dtype=numpy.int8)
session.configure_vertical(voltage_range, niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(50000000, record_length, 50.0, num_records, True)
with session.initiate():
waveform_infos = session.channels[channels].fetch_into(wfm=wfm, num_records=num_records)
The waveform_infos returned from fetch_into is a 1D list of Python objects
Attributes:
relative_initial_x (float) the time (in seconds) from the trigger to the first sample in the fetched waveform
absolute_initial_x (float) timestamp (in seconds) of the first fetched sample. This timestamp is comparable between records and acquisitions; devices that do not support this parameter use 0 for this output.
x_increment (float) the time between points in the acquired waveform in seconds
channel (str) channel name this waveform was asquire from
record (int) record number of this waveform
gain (float) the gain factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
offset (float) the offset factor of the given channel; useful for scaling binary data with the following formula:
voltage = binary data * gain factor + offset
samples (numpy array of datatype used) floating point array of samples. Length will be of the actual samples acquired
Such that all record 0 waveforms are first. For example, with a channel list of 0,1, you would have the following index values:
- index 0 = record 0, channel 0
- index 1 = record 0, channel 1
- index 2 = record 1, channel 0
- index 3 = record 1, channel 1
- etc.
API Reference¶
- Session
- Methods
- abort
- acquisition_status
- add_waveform_processing
- auto_setup
- clear_waveform_measurement_stats
- clear_waveform_processing
- close
- commit
- configure_chan_characteristics
- configure_equalization_filter_coefficients
- configure_horizontal_timing
- configure_trigger_digital
- configure_trigger_edge
- configure_trigger_hysteresis
- configure_trigger_immediate
- configure_trigger_software
- configure_trigger_video
- configure_trigger_window
- configure_vertical
- disable
- export_attribute_configuration_buffer
- export_attribute_configuration_file
- fetch
- fetch_array_measurement
- fetch_into
- fetch_measurement_stats
- get_equalization_filter_coefficients
- get_ext_cal_last_date_and_time
- get_ext_cal_last_temp
- get_self_cal_last_date_and_time
- get_self_cal_last_temp
- import_attribute_configuration_buffer
- import_attribute_configuration_file
- initiate
- lock
- probe_compensation_signal_start
- probe_compensation_signal_stop
- read
- reset
- reset_device
- reset_with_defaults
- self_cal
- self_test
- send_software_trigger_edge
- unlock
- Properties
- absolute_sample_clock_offset
- acquisition_start_time
- acquisition_type
- acq_arm_source
- advance_trigger_terminal_name
- adv_trig_src
- allow_more_records_than_memory
- arm_ref_trig_src
- backlog
- bandpass_filter_enabled
- binary_sample_width
- cable_sense_mode
- cable_sense_signal_enable
- cable_sense_voltage
- channel_count
- channel_enabled
- channel_terminal_configuration
- data_transfer_block_size
- data_transfer_maximum_bandwidth
- data_transfer_preferred_packet_size
- device_temperature
- enabled_channels
- enable_dc_restore
- enable_time_interleaved_sampling
- end_of_acquisition_event_output_terminal
- end_of_acquisition_event_terminal_name
- end_of_record_event_output_terminal
- end_of_record_event_terminal_name
- end_of_record_to_advance_trigger_holdoff
- equalization_filter_enabled
- equalization_num_coefficients
- exported_advance_trigger_output_terminal
- exported_ref_trigger_output_terminal
- exported_start_trigger_output_terminal
- flex_fir_antialias_filter_type
- fpga_bitfile_path
- glitch_condition
- glitch_polarity
- glitch_width
- high_pass_filter_frequency
- horz_enforce_realtime
- horz_min_num_pts
- horz_num_records
- horz_record_length
- horz_record_ref_position
- horz_sample_rate
- horz_time_per_record
- input_clock_source
- input_impedance
- instrument_firmware_revision
- instrument_manufacturer
- instrument_model
- interleaving_offset_correction_enabled
- io_resource_descriptor
- is_probe_comp_on
- logical_name
- master_enable
- max_input_frequency
- max_real_time_sampling_rate
- max_ris_rate
- meas_array_gain
- meas_array_offset
- meas_chan_high_ref_level
- meas_chan_low_ref_level
- meas_chan_mid_ref_level
- meas_filter_center_freq
- meas_filter_cutoff_freq
- meas_filter_order
- meas_filter_ripple
- meas_filter_taps
- meas_filter_transient_waveform_percent
- meas_filter_type
- meas_filter_width
- meas_fir_filter_window
- meas_high_ref
- meas_hysteresis_percent
- meas_interpolation_sampling_factor
- meas_last_acq_histogram_size
- meas_low_ref
- meas_mid_ref
- meas_other_channel
- meas_percentage_method
- meas_polynomial_interpolation_order
- meas_ref_level_units
- meas_time_histogram_high_time
- meas_time_histogram_high_volts
- meas_time_histogram_low_time
- meas_time_histogram_low_volts
- meas_time_histogram_size
- meas_voltage_histogram_high_volts
- meas_voltage_histogram_low_volts
- meas_voltage_histogram_size
- min_sample_rate
- onboard_memory_size
- output_clock_source
- pll_lock_status
- points_done
- poll_interval
- probe_attenuation
- ready_for_advance_event_output_terminal
- ready_for_advance_event_terminal_name
- ready_for_ref_event_output_terminal
- ready_for_ref_event_terminal_name
- ready_for_start_event_output_terminal
- ready_for_start_event_terminal_name
- records_done
- record_arm_source
- ref_clk_rate
- ref_trigger_detector_location
- ref_trigger_minimum_quiet_time
- ref_trigger_terminal_name
- ref_trig_tdc_enable
- resolution
- ris_in_auto_setup_enable
- ris_method
- ris_num_averages
- runt_high_threshold
- runt_low_threshold
- runt_polarity
- runt_time_condition
- runt_time_high_limit
- runt_time_low_limit
- sample_mode
- samp_clk_timebase_div
- sample_clock_timebase_multiplier
- samp_clk_timebase_rate
- samp_clk_timebase_src
- serial_number
- accessory_gain
- accessory_offset
- simulate
- specific_driver_description
- specific_driver_revision
- specific_driver_vendor
- start_to_ref_trigger_holdoff
- start_trigger_terminal_name
- supported_instrument_models
- trigger_auto_triggered
- trigger_coupling
- trigger_delay_time
- trigger_holdoff
- trigger_hysteresis
- trigger_impedance
- trigger_level
- trigger_modifier
- trigger_slope
- trigger_source
- trigger_type
- trigger_window_high_level
- trigger_window_low_level
- trigger_window_mode
- tv_trigger_event
- tv_trigger_line_number
- tv_trigger_polarity
- tv_trigger_signal_format
- use_spec_initial_x
- vertical_coupling
- vertical_offset
- vertical_range
- width_condition
- width_high_threshold
- width_low_threshold
- width_polarity
- NI-TClk Support
- Repeated Capabilities
- Enums
- AcquisitionStatus
- AcquisitionType
- ArrayMeasurement
- CableSenseMode
- ClearableMeasurement
- FIRFilterWindow
- FetchRelativeTo
- FilterType
- FlexFIRAntialiasFilterType
- GlitchCondition
- GlitchPolarity
- Option
- PercentageMethod
- RISMethod
- RefLevelUnits
- RefTriggerDetectorLocation
- RuntPolarity
- RuntTimeCondition
- ScalarMeasurement
- TerminalConfiguration
- TriggerCoupling
- TriggerModifier
- TriggerSlope
- TriggerType
- TriggerWindowMode
- VerticalCoupling
- VideoPolarity
- VideoSignalFormat
- VideoTriggerEvent
- WhichTrigger
- WidthCondition
- WidthPolarity
- Exceptions and Warnings
- Examples
- gRPC Support