Sample files for VBA instrument communication



This Module, when added to your VBA project, uses the Windows IDE to access the COM ports.  The original version, attributed to David M. Hitchner, is posted hereThe version posted at left has been modified to work on 64-bit systems.

Communication Demos

The two macro-enabled Excel files linked here give examples of applying modCOMM and VISA.  (The two versions run in Windows 7 (64 bit) and XP.)  The files illustrate four communication demos:

  1. 1.Instrument communication using VISA, via GPIB and USB ports.  VISA must be installed on the PC, and in the VBA project, one must include the reference to the “VISA COM 3.0 Type Library.” I’ve had success with the VISA downloads from National Instruments and Agilent.

  2. 2.Communication with a USB DAQ - the USB-1208LS from Measurement Computing.  Aside from the required drivers, the module CBW.bas must be added to the VBA project.  (Linked here; also a part of their Universal Library.)  NOTE that their Universal Library must be installed!!  Note also that you may need the 32-bit version of CBW.bas, linked CBW32.BAS.

  3. 3. Communication through the serial port, using modCOMM.  While this can send any command to the COM port, this demo is built to use the ADR series DAQs from Ontrak Control Systems.  Note that a benefit of using DAQs through the RS-232 port is that no drivers are needed!

  4. 4.Finally, the program also demonstrates communication with a USB DAQ by using the modCOMM module.  In particular, this uses the DI-149 from DATAQ Instruments.

Live Updating Demo

While not related to instrument communication, my students have often wanted to query their sensors in an “infinite loop.”  This files illustrates a UserForm that displays the “live time,” while also responding to other programming events.

These files illustrate examples of using Visual Basic for Applications for instrument communication.  An overview is given in my paper published in the ASEE 2014 Annual Conference proceedings (link).  The Excel files below are fully commented.