SCPI control of USB/RS-232 test equipment over ethernet - Page 1
Forum section: electronics / testgear

author: rmel
author_rank: Regular Contributor
timestamp: May 28, 2020, 04:56:32 pm
content: I am looking at purchasing some used test equipment then controlling them from my PC over ethernet. Most older equipment either has support for SCPI over RS-232 or USB.I was thinking I could connect a raspberry pi running linux to each piece of equipment (via usb or a USB-RS232 converter) and use SCPI commands from the command line there (no gui), but I would like to try out some of the existing software from my PC, ala BenchVue type software. I guess what I want is to "tunnel" the SCPI command over TCP to the raspberry pi and then have the pi issue the SCPI command to the test equipment over USB/RS232.Does anyone have any experience with doing something like this or can piont me to any links?I guess, at worst, I could write my own driver for the python SCPI libraries or pyVISA, but I'd rather not start from scratch if I don't need to. Searching on this forum and google didn't turn up too much.Thanks

author: nctnico
author_rank: Super Contributor
timestamp: May 28, 2020, 05:17:05 pm
content: You can buy these boxes off-the-shelf. No need to make something yourself.Google for 'rs232 to ethernet'https://www.perle.com/products/rs232-to-ethernet.shtml

author: rmel
author_rank: Regular Contributor
timestamp: May 28, 2020, 05:27:59 pm
content: Thanks for the link and the search term!That also led me to searching for "usb over ethernet server". I had only previously searched for usb to ethernet adapters/converters, which are not what I wanted.

author: alm
author_rank: Super Contributor
timestamp: May 28, 2020, 05:56:05 pm
content: With the USB over Ethernet servers, you have to be careful they support your device type. I'd expect most of them to be designed for printers or mass storage, not USB TMC, which is what I expect most test gear that support SCPI to use.

author: jhenderson0107
author_rank: Regular Contributor
timestamp: May 28, 2020, 06:02:55 pm
content: A dedicated PC running Windows 10 with NI/Keysight VISA libraries installed can be configured as a VISA server. All instruments attached to that server (via RS232, ethernet, USB or GPIB), are accessible via ethernet from applications elsewhere on the network.I use this approach to control my bench test instruments from my development PC.

author: genghisnico13
author_rank: Regular Contributor
timestamp: May 28, 2020, 06:45:03 pm
content: I have a similar setup because I already had a Pi running other tasks nearby, I'm running ser2net on the Pi and it works fine.

author: digi
author_rank: Contributor
timestamp: May 28, 2020, 10:13:45 pm
content: You could ssh into the raspberry pi using putty on your PC and then launch python from there to communicate with the connected equipment.If you want to get fancy with python there's a few ways to skin this cat:Have the raspberry pi host a python jupyter notebook and you should be able to navigate to it on your pc through a web browser and write/execute python code directlyHost a python flask web server on the raspberry pi and communicate to the equipment using a GET request by passing scpi commands in the url of a web browser and the response would be raw text shown in the web browserHost a python flask web server on the raspberry and create a webpage to handle writing/reading to equipment

author: rmel
author_rank: Regular Contributor
timestamp: May 29, 2020, 01:04:55 am
content: QuoteThanks, I had not thought about this. After see these devices, my first thought was to just connect the pi to the USB port of one of my devices and see what happens. Do I need a TMC driver for the pi to talk to a USB instrument?QuoteThis sounds like it could be what I need. I take a look, thanks.QuoteYes, there seem to be many ways to do this. My initial thoughts were to use just a simple telnet connection using paramiko or something like that, but your idea of a simple web server would work well.One thing I was thinking also was to write some kind of emulator so that software like BenchVue or something like that would see it as a device. I'm wondering if the VISA interface would allow this, but I have not even started to look at these APIs yet.Thanks everyone for your suggestions.

author: alm
author_rank: Super Contributor
timestamp: May 29, 2020, 06:13:54 pm
content: Quote from: rmel on May 29, 2020, 01:04:55 amIt depends on the instrument, but probably. I would expect anything from Keysight, Keithley etc with a USB port to use USBTMC. A $50 power supply from AliExpress, maybe not. Cheaper units may also emulate a serial port, or implement a custom USB HID device. Installing a USBTMC driver on the Raspberry Pi should be fine. It looks like there is even a script that may do what you want for USBTMC:https://github.com/pklaus/rpi-usbtmc-gatewayI would imagine that the expensive USB to Ethernet gateways, likethis, might work with the standard drivers and software like BenchVue. But this is something you would have to test, and it would only allow one computer to access them at a time. The cheap ones, likethis, will only support printers.Quote from: rmel on May 29, 2020, 01:04:55 amThe nice thing about VISA is that it is transport-agnostic, so software shouldn't have to care if a device is connected via RS-232 or Ethernet. I don't know how freely BenchVue lets you connect to arbitrary VISA devices, but if it does, then a TCP to RS-232/USBTMC server might be sufficient.

author: rmel
author_rank: Regular Contributor
timestamp: May 30, 2020, 01:57:56 pm
content: QuoteThe USBTMC driver for the pi looks promising, and it's nice that the code is available. Thanks!QuoteThis is what I'm hoping too. I found the NI-VISA web page, and it sounds like there's a license fee required to use the drivers. I'll have to go back and re-read that.

author: alm
author_rank: Super Contributor
timestamp: May 30, 2020, 04:24:59 pm
content: You can download NI-VISA for free (or could last time I looked), but you may not need it. If you installed BenchVue, then I imagine that installed theKeysight IO Libraries, which also provides a VISA stack. It will not support NI hardware or software, but that should not matter here.What should work once you've got something setup that translates to TCP/IP, is add a custom TCPIP device in the Keysight Connection Expert, and then hopefully you can point BenchVue at that device. That's how VISA is supposed to work. It's possible that they added additional restrictions, like for a DMM with a USB port only allowing USB connections.

author: rcjoy
author_rank: Regular Contributor
timestamp: June 03, 2020, 09:02:15 am
content: Consider an Agilent E5810A GPIB/LAN gateway, which despite its name also supports RS-232 over Ethernet.The newer Keysight E5810B version also supports GPIB, RS-232, and USB.You communicate to these using the VXI-11 protocol. The nice thing about that is that you don't need toinstall the bloated Keysight drivers, and it also means you can talk to it with any OS (Windows, Linux, Mac).I found an implementation of the protocol athttps://github.com/applied-optics/vxi11Some more info athttp://optics.eee.nottingham.ac.uk/vxi11/I have used that library and the E5810A to talk to an old Tek scope that used an RS-232 interface.

author: rmel
author_rank: Regular Contributor
timestamp: June 03, 2020, 07:19:33 pm
content: QuoteI downloaded the EasyPower software for my Siglent power supply (to update my firmware) and it gave me a link to the NI-VISA download page, so that's what I have installed at the moment. However, I used that with USB over a very long extender cable. I would much prefer a network connnection, so I will take a look at the Keysight IO libraries. Thanks

author: rmel
author_rank: Regular Contributor
timestamp: June 03, 2020, 07:24:45 pm
content: QuoteThat's an interesting idea. However, I could not find anything cheaper that $800 on ebay for a used unit (I didn't look very hard), that kind of an expensive option for me. I do have some programming background and I have some rasperry pi's lying around that I can use, so my preferred approach for now is to roll my own. Thanks

author: pigrew
author_rank: Frequent Contributor
timestamp: June 03, 2020, 07:29:38 pm
content: VISA expects devices to be talked to using either VXI11 (as rcjoy mentioned) or the newer protocol HiSLIP.VXI11 has the advantage that one can directly tunnel GPIB over it, so it can handle things like group triggers and parallel poll. Otherwise, HiSLIP seems like an easier to use protocol.Over the winter, I played with writing a Python-based VXI11 server:https://github.com/pigrew/pyvxi11aioIt already has code for serving as a USBTMC proxy (it lacks handling aborts and identify, but is complete enough).(my original goal was for it to be used as a way to create a GPIB adapter that uses the USBTMC protocol, and have my python code expose it as multiple devices to the local VISA, but that was never finished)

author: rmel
author_rank: Regular Contributor
timestamp: June 03, 2020, 07:42:40 pm
content: I appreciate the link!This at the very least will help me to understand protocol better. Wading through API documentation is not the most interesting of activities!

author: tautech
author_rank: Super Contributor
timestamp: June 03, 2020, 08:16:58 pm
content: rmelHave a look here:https://www.eevblog.com/forum/testgear/program-that-can-log-from-many-multimeters/

author: rmel
author_rank: Regular Contributor
timestamp: June 03, 2020, 08:44:47 pm
content: Thanks! I'll have to look into this one as well.

author: Messtechniker
author_rank: Frequent Contributor
timestamp: June 03, 2020, 09:31:05 pm
content: Also have a look at usriot.comQuite a range of RS232 to Ethernet adapters.Have not used exactly these. But have been using for a long timenow a number of their TTL to Ethernet adapters.The drivers (Eltima based) are stable under W7 and W10.

author: Hydron
author_rank: Super Contributor
timestamp: June 04, 2020, 12:43:41 pm
content: Quote from: Messtechniker on June 03, 2020, 09:31:05 pmOuch, that's an unfortunate domain name given current events!I have used similar devices (different branding but visually identical so probably same OEM) for Ethernet to RS485 and they do the job, but you are then tied to using their custom drivers, so a solution that allows for control over a standard protocol may be better.

author: pigrew
author_rank: Frequent Contributor
timestamp: June 04, 2020, 04:30:55 pm
content: Quote from: rmel on June 03, 2020, 07:42:40 pmI agree. I hope my code is helpful (or perhaps it already fulfills your needs). My project ended up as an exercise on learning to use asyncio allowing multiple network connections in a single CPU thread (making resource locking/concurrency issues much easier to handle). I ended up being able to serve local USBTMC instruments over the local network, and connect to it with NI VISA for Windows. Getting back to the original question, Benchvue will work without any fuss, as long as you use HiSLIP or VXI11.Another caveat I should have mentioned was security: Neither VXI-11 nor HISLIP have any ability to encrypt their communications. VXI-11, since it uses SUN RPC, can handle arbitrary authentication methods, but the data wouldn't be encrypted and the NI/Keysight VISA don't handle authentication, anyway.... HiSLIP 2.0 will support TLS, but the protocol is not yet released.If you need security, you'd want to tunnel the data over SSH or OpenSSL (something which the NI and Keysight VISA wouldn't be able to do internally). VXI-11 uses a pair of TCP sockets (which would need need to be registered with a portmapper on a third port; the portmapper doesn't need to be on the same host as the VXI11 server) while HiSLIP uses a single TCP port (and thus would be easier to tunnel).I don't think that the commercial gateways provide secure connections, either.

author: bingo600
author_rank: Super Contributor
timestamp: June 05, 2020, 01:07:20 pm
content: I've been using these Nport 5410 for Ether->Serial commshttps://www.ebay.com/itm/MOXA-NPort-5410-Serial-Device-Server-4-Port-w-L-Com-DB9FT-on-3-Ports/402275354949Works excellent with lots of stuff , including Lady Heather (GPSDO sw)/Bingo