• General
  • API Documentation
  • SCPI
    • General
    • Command Reference
    • Starting Server

    Show / Hide Table of Contents
    • Setup Connection
    • Usage of NI I/O Trace to monitor the SCPI traffic
    • Command Syntax
    • Status Registering System
    • Synchronization
    • Trigger System
    • Data Formats
    • Data Transmission Formats
    • Measurements
    • Error and Event Types
    • Suffixes
    • List of Abbreviations
    • SCPI Python examples

    Setup Connection

    Raw Socket

    The basic implementation as it states by now is a RAW Socket implementation, so the connection information must be entered manually.

    Establish a connection with NI Max

    NI Max by National Instruments provides a simple and easy interface to setup and test a connection. If you want to add a new device head to Devices and Interfaces, right click Network Devices and select Create New VISA TCP/IP Resource.

    Setup with NI MAX 01

    Select Manual Entry of Raw Socket.

    Setup with NI MAX 02

    Now you have to enter the connection information. For the default settings this would be a Hostname of localhost and a port number of 5025. When entered you can validate the values you just entered. If the connection information is correct, the prompt should look like shown in the image.

    Setup with NI MAX 03 Setup with NI MAX 04

    If you want to add an alias to recognize your device more easily, you are asked to enter a name.

    Setup with NI MAX 05

    Now the setup should have been completed and you should find a new entry under your network devices. Click on Open VISA Test Panel to test the communication.

    Setup with NI MAX 06

    A new window should open up.

    Setup with NI MAX 07

    Important

    For a proper connection over RAW Socket we should adapt some settings. Under I/O Settings change the I/O Protocol to 488.2 Strings and check Enable Termination Character. Do not forget to click on Apply Changes to save your settings. This settings must be made everytime you establish a connection, so keep in mind to set these parameters in the environment you intend to program the device.

    Setup with NI MAX 08

    Afterwards head to the Input/Output tab and try to query for an identification of the device. Select the *IDN?\n command and click Query. Your device should respond with an identification string that could look something like the identification string shown in the image.

    Setup with NI MAX 09

    You successfully configured your measurement device!

    Direct code integration

    If you want to directly implement the connection into your code fragment, the important value is the resource string. The resource string contains all the relevant connection information. If you set up the connection in NI MAX the resource string can be found under Network Devices - select your device - VISA Resource Name.

    Setup with NI MAX 06

    The default resource name is TCPIP0::localhost::5025::SOCKET.

    The different connection setup depends on your programming environment. The default setup for some setups are shown below, for more information please refer to the VISA library distributers documentation.

    Note

    Do not forget to adapt the settings for I/O Protocol and Termination Character

    • C#
    • Python
    • LabView
    • MatLab
    using NationalInstruments.Visa; // or similar library
    ...
    var visaSession = new TcpipSocket(VISA_RESOURCENAME);
    visaSession.TerminationCharacterEnabled = true;
    visaSession.RawIO.Write("*IDN?\n");
    Console.WriteLine(visaSession.RawIO.ReadString());
    
    # use pyvisa or similar package
    import pyvisa as visa
    ...
    visaSession = visa.ResourceManager().open_resource(VISA_RESOURCENAME)
    visaSession.read_termination = '\n'
    visaSession.io_protocol = 4 # sets the I/O Protocol to 488.2 Strings, if accessable
    print(visaSession.query("*IDN?\n"))
    

    Lab View Setup

    Depends on the visa library that should be used. If using the NationalInstruments library use ni as the first parameter.

    vs = visa('ni','VISA_RESOURCENAME');
    
    Back to top Generated by DocFX