Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Java library for VISA (Virtual Instrument Software Architecture) instruments

License

NotificationsYou must be signed in to change notification settings

pfroud/JVisa

Repository files navigation

VISA (Virtual Instrument Software Architecture) is an API for communicating with test & measurement instruments.

JVisa is a library for using VISA instruments in a Java program.

JVisa has been tested on Windows 7, Windows 10, Windows 11, and macOS 10.15. I think it should work on Linux too.

A small number of VISA functions been implemented, but it's definitely enough to do instrument automation.

Motivation

This project is a fork of Günter Fuchs'sproject of the same name, which is hosted on SourceForge.

Günter set upJNAerator andJava Native Access to interact with VISA DLLs. That was a significant step forward.

However, there were some issues in the original JVisa:

  • Confusing inheritance between theJVisa andJVisaInstrument classes
  • Only one instrument can be opened at a time
  • C-style error handling and output arguments

This fork of JVisa addresses those issues.

Getting started

Install a VISA implementation

You must install a VISA implementation to use JVisa.National Instrument NI-VISA is recommended.

As far as I know, four companies have written their own VISA implementation: Keysight, National Instruments, Rohde & Schwarz, and Tektronix.

The Nation Instruments implementation appears to be the most common. For instance,PyVISA only supports NI-VISA, and Rigol software uses NI-VISA.

I tried out all four implementations and took notes and screenshots. See mycomparison of VISA implementations.

Add JVisa to your project

Using build automation tools

You can use JitPack, visithttps://jitpack.io/#xyz.froud/JVisa/2.0.0 for details.

Example for Maven:

<repositories>    <repository>        <id>jitpack.io</id>        <url>https://jitpack.io</url>    </repository></repositories>...<dependency>    <groupId>xyz.froud</groupId>    <artifactId>JVisa</artifactId>    <version>2.0.0</version></dependency>

Jitpack also builds and hosts Javadoc:https://javadoc.jitpack.io/xyz/froud/JVisa/2.0.0/javadoc

Using a Jar file

To manually download JVisa jar files, go tohttps://github.com/pfroud/JVisa/releases.

JVisa depends on theJava Native Access (JNA) library.

If you want a single jar file containing both JVisa and JNA, useJVisa-[version]-with-dependencies.jar.

If you already have a JNA jar file, you can useJVisa-[version].jar.

To download JNA jar files, I recommendhttps://mvnrepository.com/artifact/net.java.dev.jna/jna. First, click the version number of the newest version. Then, find the table row labeled "Files" and click on "jar".

Basic usage

Start by creating a Resource Manager:

JVisaResourceManagerrm =newJVisaResourceManager();

You can search for available instruments, or you can directly open an instrument if you already know its resource name:

String[]resourcesNames =rm.findResources();JVisaInstrumentinstrument =rm.openInstrument("USB0::0xFFFF::0x1234::123456789123456789::INSTR");

Examples of how to interact with the instrument:

StringmanufacturerName =instrument.getManufacturerName();StringmodelName =instrument.getModelName();instrument.write("source:voltage 12V");instrument.write("output on");Stringresponse =instrument.queryString("measure:current?");

When finished:

instrument.close();rm.close();

Complete example code files

Thejvisa_example folder contains a few example files:

There is also a small example of how to make a higher-level abstraction. The fileAbstractionExample.java shows howAbstractInstrument.java andPowerSupplyExample.java let you call a method likesetVoltage(12) instead ofwrite("source:voltage 12V").

Run examples from jar file

It is possible to run the examples directly from the jar file.

If you have a JVisa jar file which contains the JNA dependency:

java -classpath"C:\path\to\JVisa-[version]-with-dependencies.jar" xyz.froud.jvisa_example.FindResourcesExample

Otherwise, specify a path to a JNA jar file, separated with a semicolon:

java -classpath"C:\path\to\JVisa-[version].jar;C:\path\to\jna-[version].jar" xyz.froud.jvisa_example.FindResourcesExample

For documentation about thejava command, seehttps://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html.

Glossary

Here are some initialisms you might encounter when learning about test & measurement software.

About

Java library for VISA (Virtual Instrument Software Architecture) instruments

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp