Giter VIP home page Giter VIP logo

netvisa's Introduction

Readme

Description

This is a minimalistic wrapper around NI-VISA's 64 bit dll.

National Instrument's current C# solution is only available for .NET Framework 4.8.

This project is written in .NET 6.0 but can be compiled for whatever version you are using.

Special Thanks

I used the Rohde-Schwarz Visa implementation as a guide for creating this small project. Their Nuget Package "RsInstruments" is a very powerfull implementation of Visa and freely available under the MIT license.

Unfortunately, I needed something closer to the metal that could be adapted to work with older equipement.

Prerequisites

Install NI-VISA.

This will place the visa64.dll on your computer. This code references that dll.

Example

See TestingNetVisa\Program.cs

using NetVisa;

namespace MyApp;

public class Program
{
    static void Main(string[] args)
    {
        // Create a resource manager.
        // This creates a singleton that will close when the app terminates.
        var rm = Resource_Manager.Get;

        // Read all the resources connected to this PC
        var resources = rm.FindResources();

        // Show them on the console
        Console.WriteLine(string.Join('\n', resources));

        // Create a connection to a power supply
        using var visa = new Visa_Session("GPIB0::29::INSTR", rm);

        // Set the timeout
        visa.Timeout = 5000;

        // Write
        visa.Write("VSET 5");

        // Read
        var vset = visa.ReadString();

        // Prints: "VSET 0.000   \r\n"
        Console.WriteLine('"' + vset.Replace("\n", @"\n").Replace("\r", @"\r") + '"' + "\n");
    }
}

Disclaimer

I am not responsible for this code. I make no guarantees. This is really meant as a starting point for others to continue the project if they are interested.

This works with GPIB. In theory, this also works for Ethernet (Sockets), Serial (USB), VXI11, and LXI instruments. But I haven't tried it.

Helpful References:

https://www.ni.com/docs/en-US/bundle/labview/page/lvinstio/visa_find_resource.html

https://www.ni.com/docs/en-US/bundle/ni-visa/page/ni-visa/vireadstb.html

https://pyvisa.readthedocs.io/en/1.8/shell.html

https://forums.ni.com/t5/Measurement-Studio-for-NET/Ni-DAQmx-NET6-Support/m-p/4272106#M21908

https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/cdaqmx/help_file_title.html

https://www.ni.com/docs/en-US/bundle/ni-visa/page/ni-visa/description_of_the_api.html

C:\Program Files\IVI Foundation\VISA\Win64\Include\

https://documentation.help/VISA.NET/VISA%20Attributes%20Table.htm

Definitions

SRQ => Visa Service Request

This is used for the instrument to communicate back to the controller at a time when the controller is not planning to talk with the device. https://documentation.help/NI-VISA/StatusServiceRequestService.html

OPC => Operation Complete

You can send multiple commands to an instrument and they will be queued by the instrument. However, before querying the instrument it is best to make sure the "Operation Completed" using the "*OPC?" command. https://www.keysight.com/us/en/lib/resources/training-materials/using-opc.html

netvisa's People

Contributors

jrdnwrth avatar

Stargazers

Eli Barber avatar  avatar  avatar Na Silin avatar  avatar  avatar Kalib.Gao avatar Thomas avatar  avatar

Watchers

 avatar Dardo avatar

Forkers

artyomyo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.