PHP and VISA

  • Posted by Mike Naberezny in PHP

    For a short time now, I have been interested in hooking up PHP with VISA (Virtual Instrument Software Architecture) to allow Windows users of PHP to control any I/O that is supported by the VISA standard. This includes serial, GPIB, VXI, PXI, USB, and other interfaces. I think that PHP would be a very good language for test automation in general because of its easy syntax and large number of convenience functions for string handling and other tasks common to instrument control.

    I thought that I had a made a significant discovery when I learned about VISA-COM, a set of COM interfaces to VISA. Accessing VISA through COM in PHP would be very convenient. I spent some time looking at NI-VISA‘s implementation of VISA-COM and also talking to the folks over at National Instruments. Unfortunately, the VISA-COM interfaces are not based on IDispatch so they cannot be used late-bound from scripting environments. Code written in VBScript to use VISA-COM will not work, however that same code will indeed work in Visual Basic 6.0. PHP 5 will also not be able to make use of VISA-COM.

    With VISA-COM out of the picture, that leaves two options. The FFI extension in PECL replaces the old W32API extension for PHP 4 and provides a “Foreign Function Interface” for PHP5 to access external libraries. FFI development seems slow and its present state may not have all of the functionality required to control the VISA DLL. However, it’s definitely worth some experimentation. The other option, which is perhaps the most desirable, is to create PHP bindings for VISA as a PHP extension.