Author Topic: Instrument Control Confusion  (Read 1350 times)

0 Members and 1 Guest are viewing this topic.

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Instrument Control Confusion
« on: March 04, 2018, 03:47:11 am »
I'd like to set up a test system that would control various instruments - power supply, scope, signal generator - and run a sequenced test to power up, apply inputs,  view and save results.  I have done quite a bit of programming before in VB and C and all (but one) of my PCs run Windows 10.

I can see that my Rigol instruments can be controlled using LXI and there's a Rigol instrument control package called UltraSigma but will it also control  other stuff like my Keysight scope and Multimeter?

I played with installing the VISA drivers to 'talk' to my older GPIB equipment but it was a 1.6 GByte download!  I did get it working though.

I've also read that many people work with Excel and VB which I'm somewhat familiar with and I have Office 365 on all my computers.

So what direction should I take?  I'm happy to put some time into learning but I don't want to waste effort going up blind alleys.

Thanks in advance for any advice.
 

Online H.O

  • Frequent Contributor
  • **
  • Posts: 561
  • Country: se
Re: Instrument Control Confusion
« Reply #1 on: March 04, 2018, 06:23:08 am »
I'm certainly no expert in this field (either) but I'd say you should think of Rigol Ultra Sigma more as an "umbrella" application for Rigol instruments and applications.
You can use it to "find" your instruments and their device id's or adresses on the bus in question (be it LAN, USB, serial or GPIB). You you can use it to send SCPI commands to the instruments and in some cases grab a screenshot from instrument but Ultra Sigma won't actually do anything useful when it comes to actually automating your measurment.

I've played around ever so slightly with Python and pyvisa and have managed to Control my Power supply and multimeter but I have not done any serious work with it.

If you know your way around VB and/or C and have access to VisualStudio then I'd probably use that. I'm sure other, more experienced, members will chime in and if you look around the forum a bit there's been a few discussions like this one.
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #2 on: March 04, 2018, 07:03:00 am »
Thanks, I'd read that Ulra Sigma was pretty basic. I do have VS 2017 so I could create a VB form but can anyone give me any pointers on the drivers I need to install and set up for LXI and the other stuff?
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 1170
  • Country: 00
Re: Instrument Control Confusion
« Reply #3 on: March 04, 2018, 08:57:46 am »
There are VISA .NET and VISA-COM bindings that you could use. You should be able to find C# code samples on the NI and Keysight websites that you could translate to VB.NET. Yes, VISA is a huge, bloated thing, but it allows you access pretty much any kind of instrument interface (RS-232, GPIB, LXI, USB-TMC and so on) transparently (i.e. you would not notice the difference between LXI or USB-TMC apart from the connection string), and pretty much all commercial instrument control software (like LabView) is built on it. If you want an even higher level abstraction, you could try to find IVI drivers for your instruments. You should be able to find them for your Keysight instruments, at least. Not sure about Rigol.

Software from instrument manufacturers invariably only support a small subset of instruments from that particular manufacturer, so it's useless once you want to combine instruments from different manufacturers. The closest thing I've seen to a cross-instrument GUI is NI SignalExpress, but that's not particularly light-weight or cheap.
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #4 on: March 04, 2018, 09:52:33 am »
Thanks, I have a lot of reading to do. 

I have written VB.NET programs before but I'm more familiar with C so would the C# option likely be easier for me to get into?

Also, are the VISA.NET/COM drivers from NI free?
 

Offline EE-digger

  • Regular Contributor
  • *
  • Posts: 97
  • Country: us
Re: Instrument Control Confusion
« Reply #5 on: March 04, 2018, 10:05:20 am »
Agilent / Keysight IO libraries is large but sits quietly in the background once you install it.  It's VISA and the NI VISA should be compatible.

Agilent and HP had tons of examples in C, VB and Rocky Mountain Basic  :)  Most of their instruments had programming manuals or examples in the user guide if smaller.  Examples were usually pretty clear.

I'm HW and don't program much but have used C# to create a remote interface for an Agilent PSA.  It's a WIP but works quite well over LAN.

I'm not using libraries of the kind that NI may provide for an entire function set of an instrument, but rather writing small apps to do only what I need.  The nice thing about this is you can create special functions you invoke with a single button.

For Excel examples (in VB) that work as tool add-ins, have a look at IntuiLink (SP??) from Agilent.  It's no longer updated but you may still be able to download for older instruments.
« Last Edit: March 04, 2018, 10:10:28 am by EE-digger »
 
The following users thanked this post: Gandalf_Sr

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #6 on: March 04, 2018, 11:44:20 am »
I have 3 main categories or gear 1) Old GPIB that I hooked up via an Agilent E5810A LAN/GBIP gateway - the GPIB stuff is an E4433B ESG-D sig gene and old HP/Agilent Power Supplies 2) LAN-connected stuff like an N1996A Spectrum Analyzer, an Agilent 34461A bench multimeter 3) Rigol and Siglen scopes and PSUs that are LXI LAN or USB

alm says that the NI drivers (which seem to be free) will allow connection to all my test gear but surely the Agilent / Keysight IO libraries will only talk to Agilent / Keysight test gear?
 

Offline EE-digger

  • Regular Contributor
  • *
  • Posts: 97
  • Country: us
Re: Instrument Control Confusion
« Reply #7 on: March 04, 2018, 02:48:45 pm »
The Agilent / Keysight libraries would be used by Agilent / Keysight tools like Bench (DMM, SA, NA, etc.) and a nice marketing blunder called DMM Connectivity utilities.  The latter has no time limit on DMM logged data records while "Bench" demo limits to 1 hour.  I use it a lot with my 34401A and it should support most of your newer DMM functions.

I have a E4432B ESG-D and have also controlled that using C# code. 

You can talk to any other brand of instrument but that would be via your code and VISA which is installed with the whole suite.

Over the years, NI was too bloated for me and today, also too expensive.  But lots of people pull together clusters of unrelated instruments using their products.

If you want to pull everything together into a system (your original goal), then you may want NI-Labview, unless you build it from your own pieces of code.
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #8 on: March 04, 2018, 08:59:40 pm »
Thanks EE-digger, I have a lot of reading and research to do.
 

Offline CrazyTiger

  • Contributor
  • Posts: 13
  • Country: my
Re: Instrument Control Confusion
« Reply #9 on: March 06, 2018, 12:26:17 pm »
There is another alternative which is using NI Visa .dll instead on Keysight I/O. Most of the examples on internet is using C#, I have whipped up a simple base software using NI Visa and VB.Net, I think this sample will give you a platform to begin.

Requirements:
NI Drivers, you can download this in from NI Website ( i am using version 14, but anything else should work), its a big download worth the download
Visual Studio 2012 and above :), and you have to add references accordingly.

Some info:
In the textbox you have to fill up the visa resource:
Example if you are using GPIB address 28, The visa string should be:
GPIB0::28::INSTR
I have programmed it to work for TCPIP connection too, just change the resource string to tcpip accordingly.

The software basically just send an *IDN? command and outputs the result to a message box, but its meant to show how you can use NI Visa to control various resource.

*You can get visa string from NI Max software.
Btw I am dirty programmer, so dont blame me if it looks horrible  :-DD
 
The following users thanked this post: Gandalf_Sr

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #10 on: March 07, 2018, 11:22:59 pm »
Thanks CrazyTiger, I'm trying your route.  I downloaded the NI VISA drivers 17.5 which was 756 MBytes and now it's doing 2 critical updates that are 304 and 501 MBytes.  Good job I have an insanely fast (150 MBs) connection. Next thing will be to try your example program.
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #11 on: March 08, 2018, 01:10:05 am »
CrazyTiger, I am running into some problems where my VS2017 environment is not finding all the references e.g. NationalInstruments.Common.  I can see that those file assemblies exist on my C: drive but it won't let me type in the path to them.  I think this may be because the solution was written in a different version of VB.NET?

After installing NI Drivers 17.7, is there a step needed to add it to VS2017 that I missed?

Please see the screen shot below for my project screen - I've tried a few different Target Frameworks but no joy so far.  Any ideas?

Thanks in advance.

Ted
 

Offline CrazyTiger

  • Contributor
  • Posts: 13
  • Country: my
Re: Instrument Control Confusion
« Reply #12 on: March 08, 2018, 02:25:34 am »
Visual Studio works weird in this way, it never automatically find all the reference  |O. You will have to add reference on your project.
Regarding framework anything above version 4 should be fine.

Try hitting project->add reference->browse and point to the directory the dll is sitting
Most of the time both this .dll sits in the following path:
C:\Program Files\National Instruments\MeasurementStudioVS2010\DotNET\Assemblies\Current
MeasurementStudioVS2010--> this is subject to what is installed

I am attaching my .dll, you can point the reference to this .dll instead
1. NationalInstruments.NI4882 --> This is specifically to control GPIB (not used in this example, but just add it for fun)
2. NationalInstruments.VisaNS --> This is the visa control, and give control to USB, Serial, GPIB, TCPIP..etc

Btw if you are intending to control multiple instrument, do have a look into parallel polling and how to use *OPC, *WAI and will be super useful :)4
This is a good document on how to put instrument on hold while querying for result, its not meant for VB but the concept is the same.
https://cdn.rohde-schwarz.com/pws/dl_downloads/dl_application/application_notes/1ef62/1EF62_1E.pdf


Good Luck :)

Update:
looks like Measurement Studio VisaNS .NET class library is replaced byNI-VISA .NET API. The latest Visual Studio version supported by VisaNS is 2013.
I will reconvert back the example, to newer version tomorrow, have to get visual studio 2017 first. 

« Last Edit: March 08, 2018, 02:57:26 am by CrazyTiger »
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #13 on: March 08, 2018, 04:26:15 am »
Thanks for your help CrazyTiger,

There are various .com reference available to me that are shown in the pictures below.  If anyone wants to sing along; all of what I'm trying to work with here is free software but I'll warn you that the downloads are HUGE.

Microsoft's Visual Studio 2017 is a free IDE (Integrated Development Environment) and allows you to work with multiple languages - it facilitates creating windows forms using VB.NET or C# that will run on PCs.  The Drivers that CrazyTiger is helping to get running in VS 2017 are the VISA drivers from National Instruments www.ni.com - going on for 2 Gbytes of downloads for version 17.5 after it's applied all its automatic updates - you'll need to register accounts with Microsoft and NI.  I think this is going to end up with a development environment that will allow connection to pretty much any instrument via LAN or GPIB or USB?

I've written a couple of Visual Basic.NET forms before so I think I can crawl; once I learn to walk, I'd like to try to write a calibration form that calibrates my new DP832 power supply using my Keysight 34461A, 6.5 digit Multimeter, via the LAN connections.  The code steps to do this are already in these forums, typically in Python but I haven't worked with it much.
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #14 on: March 08, 2018, 04:35:48 am »
This looks useful... https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9fESAS

[EDIT] I have also just been made aware of a package called Keysight Command Expert which is a free download; it seems to offer a stand alone & bridge capability to connect to various instruments and then plug into various packages including VS and Excel. You can read about it here https://www.keysight.com/en/pd-2036130/command-expert?pm=PL&nid=-33002.992473&cc=US&lc=eng

The question I haven't answered yet is how to connect to non-Keysight test gear but there appears to be a "create an instrument" feature and it says you can import a list of commands that the instrument understands. It claims that you can set up and test a command sequence from withing Command Expert and then export to VS2017 with it writing the VB.Net code for you; if it does this, it would be a great time saver. I think I'm going to download and play with it this weekend.
« Last Edit: March 09, 2018, 09:21:10 pm by Gandalf_Sr »
 

Offline CrazyTiger

  • Contributor
  • Posts: 13
  • Country: my
Re: Instrument Control Confusion
« Reply #15 on: March 13, 2018, 05:34:24 pm »
Sorry for the delay. I basically has to set up a Virtual Machine running Win 10, VS 2017 and NI Drivers to check what kind of compile error you were facing  :phew:

Microsoft have a free virtual machine image with VS 2017 pre-installed, its a 65 day evaluation version, but its good enough for most work
https://developer.microsoft.com/en-us/windows/downloads/virtual-machines

Prerequisite:
1. Win 10
2. Visual Studio 2012-2017
3. NI Drivers (both NI 488.2 and NI Visa)
4. GPIB Hardware, I am using GPIB-USB-HS+ (kind of a overkill, but I suppose any NI based GPIB hardware works, Agilent usb devices works too)

Step 1: Install all the drivers obviously :P. But when NI drivers are being installed make sure you are installing all the development framework related drivers too, these are not installed by default.

Step 2: Open TestVisa.sln, on the codes section, notice all those squiggly red line, these is because the reference's are not added to the project.

So goto project->add reference hit browse and point it to the reference(attached in the post earlier). It should look like in the picture:

Step 3: Compile and Test   :)

I tested with my 34410A, It has GPIB and LAN :). The visa string is subject to change based on instrument but here is mine :)


1. GPIB, visa string was : GPIB0::15::INSTR
2. TCPIP, visa string is TCPIP0::a-34410a-14983::inst0::INSTR


Next up, I will modify the software to work with the latest NI 2017 Driver. Version 2 to come, right after I get windows 10 to work without crawling  |O
« Last Edit: March 13, 2018, 05:38:51 pm by CrazyTiger »
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #16 on: March 13, 2018, 08:33:15 pm »
CrazyTiger, Thanks, it is probably the drivers that are not installed by default that is causing my problem - I may not get to try this until the weekend.
 

Offline lundmar

  • Frequent Contributor
  • **
  • Posts: 345
  • Country: dk
Re: Instrument Control Confusion
« Reply #17 on: March 18, 2018, 07:35:18 am »
Alternatively you could try out lxi-tools.

The lxi-tools open source project provides the following:

    "lxi" - a command line tool that features a simple interface for discovering LXI compatible instruments, sending SCPI messages, capturing screenshots, benchmarking, and scripted automation
    "lxi-gui" - a GUI application that features some of the same features as the command line tool and additional features such as a screenshot viewer and a data recorder
    "liblxi" - a C library which provides a high level API for LXI instrument discovery (using VXI-11 or mDNS/DNS-SD) and basic SCPI communication (using RAW/TCP or VXI-11/TCP)

For more information see
http://lxi-tools.github.io
https://github.com/lxi-tools/lxi-tools
https://github.com/lxi-tools/liblxi
http://www.eevblog.com/forum/testgear/open-source-lxi-tools-and-liblxi-v1-0-released-for-gnulinux/?all

The only downside is that it is not available for Windows yet. However, it can easily be installed and run in a VM in Windows using e.g. VirtualBox/Ubuntu.

lxi-tools might be particular interesting for this discussion thread because it recently gained a Lua scripting feature to support exactly the kind of automation you are talking about without having to download and install gigabytes of data or special drivers (its driver less).

For example, with lxi-tools you can run a simple Lua script that contains the following script code to read out the RMS voltage statistic of a Rigol ds1000z series oscilloscope:
Code: [Select]
dso = connect("192.168.1.112")
volt_rms = scpi(dso, ":MEASure:STATistic:ITEM? current,vrms")
volt_rms = tonumber(volt_rms)
if (volt_rms < 4.5) then
    print("Voltage is too low!")
end
disconnect(dso)

To run the script simply do:
Code: [Select]
$ lxi run test-ds1000z.lua
Voltage is too low!

A slightly more advanced script communicating with two instruments can be seen here:
https://github.com/lxi-tools/lxi-tools/blob/master/test/test.lua

There is a also a test script which demonstrates various Lua features:
https://github.com/lxi-tools/lxi-tools/blob/master/test/basic-tests.lua

As you can see it is really simple yet powerful.

By all accounts I think it is exactly what you are looking for, except it is not available for Windows yet. Also, it has been tested with many instruments, in particular Siglent and Rigol.

Recently Siglent wrote an application note about how to use lxi-tools with their instruments:
https://www.siglentamerica.com/application-note/lxi-tools

And this is lxi-tools running on Windows in a VirtualBox Ubuntu VM:
« Last Edit: March 18, 2018, 11:22:58 am by lundmar »
https://lxi-tools.github.io - Open source LXI tools
https://tio.github.io - A simple TTY terminal I/O application
http://dc-power-supply.github.io - OSHW DC power supply project
 
The following users thanked this post: Gandalf_Sr

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #18 on: March 19, 2018, 07:09:28 pm »
lundmar (and all) thanks.  Had a death in the family over the weekend so not keeping up with this right now.
 

Offline pwlps

  • Newbie
  • Posts: 4
  • Country: fr
Re: Instrument Control Confusion
« Reply #19 on: April 26, 2018, 08:06:43 pm »
If you want to use C# or VB.NET you can try my library:

https://www.codeproject.com/Articles/1166996/Multithreaded-communication-for-GPIB-Visa-Serial-i

It may be of interest if you use different interfaces in the same app because the I/O functions are the same for all interfaces (in my lab I'm using many different instruments sometimes with different interfaces and wanted to have a uniform API so I don't need to change much the code when switching between different GPIB boards or from GPIB to USB etc.).  The library is aimed at speed (asynchronous I/O) because I have many instruments to scan, but if you don't need it you can just use the standard blocking I/O.
For Visa  I'm not using the NET API's (mainly because I found the old-style plain C dll much better documented), it is based on calls to Visa32.dll.  This might cause a little problem if you want to have both NI and Keysight Visa installed: then you would have to check what is the actual dll name used and change it in the code.
 

Offline Gandalf_Sr

  • Frequent Contributor
  • **
  • Posts: 570
  • Country: us
Re: Instrument Control Confusion
« Reply #20 on: April 26, 2018, 08:16:10 pm »
Merci
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf