Basic Usage

You can use the NI-SCOPE .NET class library to interactively program NI high-speed oscilloscopes and digitizers. The NI-SCOPE .NET API is an Interchangeable Virtual Instrument (IVI)-compliant instrument driver that features a set of methods and properties that exercise the functionality of the NI-SCOPE hardware.

  1. Initialization—Use a constructor to create a new instance of the NIScope class. You must create an instance of this class before you can call into the underlying NI-SCOPE driver.
    VB.NET
    
    Using scopeSession As New NIScope("resourceName", false, false)
        ' Initialize a session to NI-SCOPE instruments.
        ' Your code goes here. 
    End Using
         
    
    C#
    
    using (NIScope scopeSession = new NIScope("resourceName", false, false))
    {
          // Initialize a session to NI-SCOPE instruments.
          // Your code goes here.
    }
    
  2. Configuration—Use the NIScope object to access various sub-objects and to configure the NI-SCOPE driver directly or indirectly. You can use a sub-object of the ScopeChannelCollection class to configure channel-specific properties.
    VB.NET
    
    Dim scopeSession As New NIScope(ResourceName, False, False)
    scopeSession.Channels(ChannelName).Configure(VerticalRange, VerticalOffset, ScopeVerticalCoupling.DC, 1.0, True)
    scopeSession.Timing.ConfigureTiming(sampleRateMin, recordLengthMin, refPosition, 1, True)
    Dim recordLength As Long = scopeSession.Acquisition.RecordLength
    scopeSession.Measurement.Initiate()
    Dim byteWaveforms As AnalogWaveformCollection(Of Byte) = scopeSession.Channels(ChannelName).Measurement.FetchByte(timeout, recordLength, byteWaveforms, waveformInfo)
    
    C#
    
    NIScope scopeSession = new NIScope(ResourceName, false, false);
    scopeSession.Channels[ChannelName].Configure(VerticalRange, VerticalOffset, ScopeVerticalCoupling.DC, 1.0, true);
    scopeSession.Timing.ConfigureTiming(sampleRateMin, recordLengthMin, refPosition, 1,true);
    long recordLength = scopeSession.Acquisition.RecordLength;
    scopeSession.Measurement.Initiate();
    AnalogWaveformCollection<byte> byteWaveforms = scopeSession.Channels[ChannelName].Measurement.FetchByte(timeout, recordLength, byteWaveforms, out waveformInfo);
  3. Initiate—NI-SCOPE devices start acquiring waveforms, causing the NIScope session to enter the running state.
    VB.NET
    
    scopeSession.Measurement.Initiate()
    
    C#
    
    scopeSession.Measurement.Initiate();
    
  4. Running State—In the Running state, you can take measurements, fetch buffered measurements, query the output state, or query device states.
    VB.NET
    
    Dim recordLength As Long = scopeSession.Acquisition.RecordLength
    Dim sampleRate As Double = scopeSession.Acquisition.SampleRate
    Dim byteWaveforms As AnalogWaveformCollection(Of Byte) = scopeSession.Channels(ChannelName).Measurement.FetchByte(timeout, recordLength, byteWaveforms, waveformInfo)
    C#
    
    long recordLength = scopeSession.Acquisition.RecordLength;
    double sampleRate = scopeSession.Acquisition.SampleRate;
    AnalogWaveformCollection<byte> byteWaveforms
    = scopeSession.Channels[ChannelName].Measurement.FetchByte(timeout, recordLength, byteWaveforms, out waveformInfo);
  5. Close—Closes the session to the device(s) and frees un-managed resources that are held by the session. You can close the session with Close or Dispose.
    VB.NET
    
    scopeSession.Close()
    or
    scopeSession.Dispose()
    or 
    Using scopeSession As New NIScope("resourceName", false, false)
        ' Your code goes here. 
    End Using
    C#
    
    scopeSession.Close();
    or
    scopeSession.Dispose();
    or
    using (NIScope scopeSession = new NIScope("resourceName", false, false))
    {
        // Your code goes here.
    }

Refer to the Programming Flow topic in the NI High-Speed Digitizers Help for information about the specific NI-SCOPE software states.