4. VISA in Programming Languages

There are many programming languages offering the possibility to remotely control Test & Measurement instruments.

In this guide, we focus on:

  • Python in R&S Forum
  • Python in PyCharm
  • MATLAB®
  • C# in Visual Studio Development Environment
  • LabVIEW™
  • ANSI-C in LabWindows/CVI™

In the following sub-chapters, we discuss advantages and disadvantages of each language. Included ready-to-use example for each of these languages should help you getting started. The screenshots emphasize simple code change in case you change physical connection to your instrument. They also show used layers between the application and VISA.

An installation of VISA is the common precondition for all the examples below.

Python in R&S Forum

Advantages: Easy to use, specially developed for instrument remote control, multi-platform, also offers interactive console.

Disadvantages: Difficult to develop GUIs, the environment is not suitable for bigger projects.

In R&S Forum, you change the instrument resource string in menu item Settings -> Instruments. The session to the instrument is opened with the first communication attempt. See more in the dedicated application note 1MA196

Python in PyCharm

Advantages: Intelligent code editor, safe refactoring, allows for tracking code changes, excellent debugger, also available for Linux.

Compared to pure PyVisa, RsInstrument provides many extended features - proper session attribute settings, synchronization functions, error checking, large data transfer in both directions.

Disadvantages: Missing compiler means you code is only tested for errors during execution.

In Python 3.x, you use RsInstrument module that internally uses PyVISA. You change the resource string in the RsInstrument class constructor.

MATLAB

Advantages: Simple scripting language, including easy GUI designs.

Disadvantages: No multi-threading, bulky executables.

In MATLAB you change the resource string in the VISA Open() method. The rest of your script is unchanged. See more in the dedicated application note 1MA171

C# in Visual Studio

Advantages: State-of-the-art programming environment, optimized for high performance.

Disadvantages: Requires advanced programming knowledg.

In Visual Studio C#, you use the RsInstrument assembly, which provides same features as the RsInstrument module for Python - proper session attribute settings, synchronization functions, error checking, large data transfer in both directions. You only have to change the resource string in the RsInstrument constructor. The example link below also contains a Visual Basic .NET project.

LabVIEW

Advantages: Ideal for engineers without the need for advanced programming skills, specially developed for instrument remote control applications.

Disadvantages: Lower performance by graphical tasks, difficult to compare versions due to graphical source code.

In LabVIEW, you change the instrument resource string for the LabVIEW function VISA Open. The session stays valid even if your program stops. If you are using instrument drivers, refer to the dedicated application note 1MA228

ANSI-C in LabWindows/CVI

Advantages: ANSI-C environment targeted for instrument remote control.

Disadvantages: Requires advanced programming knowledge.

In C/C++, you change the resource string in the viOpen() function. First, you need to open a resource manager with the function viOpenDefaultRM().

Request information

Do you have questions or need additional information? Simply fill out this form and we will get right back to you.

我同意通过以下方式接收罗德与施瓦茨提供的信息:

推广许可

这意味着什么?

我同意,在网站Imprint中提到的Rohde & Schwarz GmbH & Co. KG和罗德与施瓦茨实体及分支机构 可出于营销和广告之目的(例如提供特价优惠和折扣促销信息)而通过选定渠道(电子邮件或邮政信件)与我联系并提供相关信息,包括但不限于测试与测量、安全通信、监测与网络测试、广播电视与媒体以及网络安全领域的产品和解决方案相关信息

您的权利

您可以随时发送电子邮件至 news@rohde-schwarz.com 撤销此同意声明,邮件主题注明“Unsubscribe”即可。此外,我们发送给您的每一封电子邮件中都含有电子邮件取消订阅链接。有关个人数据使用和撤销程序的详情,请参阅“隐私声明”

你的申请已提交,我们稍后会联系您。
An error is occurred, please try it again later.