Instrument Control Confusion - Page 1
Forum section: electronics / testgear

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 03, 2018, 04:47:11 pm
content: 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.

author: H.O
author_rank: Frequent Contributor
timestamp: March 03, 2018, 07:23:08 pm
content: 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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 03, 2018, 08:03:00 pm
content: 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?

author: alm
author_rank: Super Contributor
timestamp: March 03, 2018, 09:57:46 pm
content: There areVISA .NETandVISA-COM bindingsthat 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 isNI SignalExpress, but that's not particularly light-weight or cheap.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 03, 2018, 10:52:33 pm
content: 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?

author: EE-digger
author_rank: Frequent Contributor
timestamp: March 03, 2018, 11:05:20 pm
content: 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 BasicMost 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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 04, 2018, 12:44:20 am
content: 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 USBalm 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?

author: EE-digger
author_rank: Frequent Contributor
timestamp: March 04, 2018, 03:48:45 am
content: 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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 04, 2018, 09:59:40 am
content: Thanks EE-digger, I have a lot of reading and research to do.

author: CrazyTiger
author_rank: Regular Contributor
timestamp: March 06, 2018, 01:26:17 am
content: 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 downloadVisual 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::INSTRI 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

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 07, 2018, 12:22:59 pm
content: 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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 07, 2018, 02:10:05 pm
content: 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

author: CrazyTiger
author_rank: Regular Contributor
timestamp: March 07, 2018, 03:25:34 pm
content: Visual Studio works weird in this way, it never automatically find all the reference. 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 sittingMost of the time both this .dll sits in the following path:C:\Program Files\National Instruments\MeasurementStudioVS2010\DotNET\Assemblies\CurrentMeasurementStudioVS2010--> this is subject to what is installedI am attaching my .dll, you can point the reference to this .dll instead1. 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..etcBtw 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 :)4This 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.pdfGood LuckUpdate: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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 07, 2018, 05:26:15 pm
content: 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 Instrumentswww.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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 07, 2018, 05:35:48 pm
content: This looks useful...https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9fESAS 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 herehttps://www.keysight.com/en/pd-2036130/command-expert?pm=PL&nid=-33002.992473&cc=US&lc=engThe 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.

author: CrazyTiger
author_rank: Regular Contributor
timestamp: March 13, 2018, 06:34:24 am
content: 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 facingMicrosoft have a free virtual machine image with VS 2017 pre-installed, its a 65 day evaluation version, but its good enough for most workhttps://developer.microsoft.com/en-us/windows/downloads/virtual-machinesPrerequisite:1. Win 102. Visual Studio 2012-20173. 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. 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 TestI tested with my 34410A, It has GPIB and LAN. The visa string is subject to change based on instrument but here is mine1. GPIB, visa string was : GPIB0::15::INSTR2. TCPIP, visa string is TCPIP0::a-34410a-14983::inst0::INSTRNext 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

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 13, 2018, 09:33:15 am
content: 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.

author: lundmar
author_rank: Frequent Contributor
timestamp: March 17, 2018, 08:35:18 pm
content: 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 seehttp://lxi-tools.github.iohttps://github.com/lxi-tools/lxi-toolshttps://github.com/lxi-tools/liblxihttps://www.eevblog.com/forum/testgear/open-source-lxi-tools-and-liblxi-v1-0-released-for-gnulinux/?allThe 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: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) thenprint("Voltage is too low!")enddisconnect(dso)To run the script simply do:Code:$ lxi run test-ds1000z.luaVoltage 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.luaThere is a also a test script which demonstrates various Lua features:https://github.com/lxi-tools/lxi-tools/blob/master/test/basic-tests.luaAs 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-toolsAnd this is lxi-tools running on Windows in a VirtualBox Ubuntu VM:

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: March 19, 2018, 08:09:28 am
content: lundmar (and all) thanks. Had a death in the family over the weekend so not keeping up with this right now.

author: pwlps
author_rank: Frequent Contributor
timestamp: April 26, 2018, 10:06:43 am
content: 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-iIt 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.

author: Gandalf_Sr
author_rank: Super Contributor
timestamp: April 26, 2018, 10:16:10 am
content: Merci