Opening and closing a NI device over GPIB
I'm currently working on a project where we're doing some automated testing.
We're using a Ro开发者_Go百科hde and Schwarz Vector Network Analyzer to do our testing, and the interface it provides for communication is GPIB. On my laptop it simply plugs in as USB.
How can I communicate with it in VB?
Thanks!
You will need to download and install the national instruments drivers for the USB GPIB connector. The DLL you will need to include is NationalInstruments.NI4882.dll
. Once you install that there are usually example projects. Then you just need to look up the GPIB commands for each of your devices (the Network Analyzer). Then just send commands via your code to control the device. GPIB Instrument Automation for Metrology Test and Measurement might be a good start.
For the Rohde and Schwarz Vector Network Analyzer, you can find the manual here. Then in each section you will see "Remote Command(s)". These are the commands you will need to send via the national instruments driver from your code to the device. For example:
public void WriteCommand(string command)
{
device.Write(command);
}
// Where you want to write the command
WriteCommand("DISPlay:THEMe:SELect"); // Select a theme
If you would like to do this from within vba inside of Excel or MSAccess it is very simple to do it.
Just add a reference to the visa com lib after you install the ni488 (free) visa com io libraries from national or agilent.
http://www.home.agilent.com/agilent/editorial.jspx?cc=US&lc=eng&ckey=474128-1-eng&nid=-536900124.0.08&id=474128-1-eng
This will work similarly from within many com aware environments other than just vba.
精彩评论