LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

looping through visa resources

I have a PXI Chassis that contains 8 serial cards.  For simplicity sake, say they're wired 1-2, 3-4, 5-6, 7-8.  So, basically, what ever I write to 1, I want to read at 2 - the same with the others.  I have the code that configures the com ports and writes/reads the data to one set of ports.  What I want to do, however, is somehow put this is a loop so as to have the com port number (enum) increment.  The two questions I have are:
 
1) If looping this way is the best way to go, how do I increment from COM port 1 to COM port 3.
 
2) On the PC where I'm developing, I just have COM1 and LPT1 that show up in my VISA Resource control drop down.  On the target, however, I know we have about 16  COM ports.  I want to test specific ones though.  Do I need to create some type of array of valid COM ports.  Is this something that I have to hard code or can I do it dynamically.
Message 1 of 13
(1,847 Views)
Highlighted

I'm probably not the best person to answer, but I think you should use an array of type 'VISA resourse name' and let your loop decide with autoindexing. It's a small array so passing it around shouldn't cause too much trouble.

I don't think you can build a 'VISA resouce name' from strings. Therefore I think the array is your best bet. The caveat is that I haven't done this before so take it for what it's worth. 🙂

-Rick

 

0 Kudos
Message 2 of 13
(1,827 Views)
Highlighted

Since the PC I'm running/developing on has a couple of Com ports itself, I want to first do a VISA Find Resource to get the list of all my Com ports.  The plan is to somehow determine which ones are in the PXI chassis (probably, I'll have to open and read some identifier to validate) and to configure only those. 

My question is how do I convert the find list array of strings (returned by VISA Find Resource), into an array of VISA Resource Name that I can then pass into my auto-indexing loop?

Message 3 of 13
(1,813 Views)
Highlighted
You don't have to. You can wire a string to the VISA Resource Name input.
Message 4 of 13
(1,811 Views)
Highlighted

That worked great.  Thanks. 

I'm having another problem now.  I wire the array into the for-loop with auto index, but within the loop, I want to configure Com Ports 1 & 2, write to port 1 and read from port 2 - in this particular test, 1-2 are connected to each other, as are 3-4, 5-6, 7-8), then move to the next set of com ports 3-4.  I don't know if the for-loop is the best way to go about what I want to do, but how do I pass in the array, auto-index, and access the current and next values in the array?

0 Kudos
Message 5 of 13
(1,799 Views)
Highlighted
You can use the for loop but you probably don't want to auto-index. Maybe if you got the array size and divided by 2 and wired this to the 'N' terminal. Inside the for loop, use the index array function to get elements 0 and 1 the first iteration, 2 and three the next, etc. A shift register will retain the index value.
 

Message Edited by Dennis Knutson on 07-27-2006 11:57 AM

Message 6 of 13
(1,796 Views)
Highlighted
Where is this "visa resource name input"?
0 Kudos
Message 7 of 13
(1,335 Views)
Highlighted
On all of the inputs of the VISA functions. If you are asking where to get a control on the front panel, get it from the I/O palette.
Message 8 of 13
(1,331 Views)
Highlighted
The input at the upper left of the connector panel on a VISA Read or VISA Write function.
Message 9 of 13
(1,327 Views)
Highlighted

Back to this issue, and I am still struggling to get the proper outputs.

 

I use the VISA FIND RESOURCE to get a nice list of serial ports, however all I really want is the connect USB devices.

 

One problem is that the list of instruments does not tell me which com ports are active.

 

Rather than figure out how to decipher these instrument codes, it seems better to just get com port numbers.

 

When I use a VISA IO control, I can refresh list and see all serial ports, with some icon beside the ones that are connected.

 

However, I cannot seem to find a property node that gives me this list displayed in the IO dropdown list.

 

Any examples available, that show how to get these "connected" USB ports?

 

0 Kudos
Message 10 of 13
(1,295 Views)