Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

In VB 6.x, which NI VISA attribute stores the CommPort for a given device?

Is it best to call the viFindRsrc method, to get the "instrDesc" argument?  The problem is, the instrDesc is a string, whereas the comm port object I want to set is a long int in my code...  any suggestions? 

 

viFindRsrc&(ByVal sesn&, ByVal expr$, findList&, retcnt&,

ByVal instrDesc$)

 

instrDesc -- OUT -- Returns a string identifying the location of a device.

Strings can then be passed to viOpen() to establish a

session to the given device.

0 Kudos
Message 1 of 6
(3,998 Views)
I'm not sure I understand the question. You do not need to call viFindRsrc() in order to use viOpen(). The rsrcName parameter of viOpen() is the descriptor name for the VISA resource that you want to open. You can create this string yourself. For example, for COM1 serial port it would be "ASRL1::INSTR".
0 Kudos
Message 2 of 6
(3,992 Views)

To give you further background: I'm in a developer group that supports a chemistry lab.  I'm updating a MS Access DB containing VBA code from Access 97/WIN NT using NI Control Works to Access 2007/WIN 7 using NI VISA.  We use your software to connect the computer/DB to one or two chemistry measurement devices via RS232 serial ports.  The thing is, the existing VBA code refers to the respective port as COM1, COM2, etc. which NI VISA refers to as "ASRL1::INSTR", as you said.  I'm trying to avoid hard-coding the port name, though, b/c there may be more than one instrument attached to the serial board at a time... and so I want to be sure I'm opening the correct port by first querying viFindRsrc().  However, I've been looking through the NI VISA Programmer Reference Manual, and I can't seem to find an attribute that directly stores the comm port value/location.  I thought it was "VI_ATTR_VXI_LA" but that doesn't seem to work for RS232 serial ports...  Is there another attribute you know of that I can use? 

0 Kudos
Message 3 of 6
(3,977 Views)
As far as I know, there is no attribute and in order to determine how many serial ports are on the pc, you need to use viFindRsc. Since this returns a list of resources, you would then need to use viFindNext() for each item in the list and do a query in order to determine if any instrument is connected and which kind is connected.
0 Kudos
Message 4 of 6
(3,965 Views)

Thanks for all your help so far!

 

On a related note, does anyone know which reference I need to check/activate in the VB Editor inside of MS Access in order for the NI Visa calls/code to work?  The only listed reference is "National Instruments Max Ctrl 1.1".  However, is there any other reference I should include from the NI Serial 3.5 driver disc? 

0 Kudos
Message 5 of 6
(3,946 Views)

CoalMiner wrote:

Thanks for all your help so far!

 

On a related note, does anyone know which reference I need to check/activate in the VB Editor inside of MS Access in order for the NI Visa calls/code to work?  The only listed reference is "National Instruments Max Ctrl 1.1".  However, is there any other reference I should include from the NI Serial 3.5 driver disc? 


The "Max Ctrl" is only if you're trying to program MAX, which you're not doing. NI-Serial is only used if you have NI serial boards or NI serial interface products like the USB<->Serial devices. If you are using the COM ports directly on the computer you do not need it. For NI-VISA you need to include niglobal.bas and vbib-32.bas. This is stated in the NI-488.2 Help file. 

0 Kudos
Message 6 of 6
(3,941 Views)