Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting serial port read.vi to VISA

In a loop I am continually reading 64 bytes/port for up to 32 ports using the old "Serial Port Read.vi" and feeding in an array of port numbers. I am trying to optimize performance and am considering switching to VISA VIs. How do I manage up to 32 port numbers with the VISA Resource name control? The control seems to default to ASRL10::INSTR,ASRL1::INSTR, ASRL2::INSTR - just three entries none of which is implicitly a port number??? Also can you suggest any other means to optimize reading many ports quickly?
thanx
Lawrence M. David Jr.
Certified LabVIEW Architect
cell: 516.819.9711
http://www.aleconsultants.com
larry@aleconsultants.com
0 Kudos
Message 1 of 8
(4,478 Views)
Hi,
I think I should first mention that I doubt VISA will affect the speed of transmission. That being said, you can configure your VISA resources in the VISA alias editor. The easiest way to access the editor is to open MAX (The Measurement and Automation Explorer) and select Tools -> VISA -> Alias Editor. From here you can alias any instrument to the desired name.

Is this what you were looking for or did I miss the point of your question?

Best Regards,
Aaron K.
Application Engineer
National Instruments
0 Kudos
Message 2 of 8
(4,474 Views)
Hi, thanks for the response. Ok this gets a bit more involved. I need to make a distributed executable available to the general public. Assuming that I don't bundle NI-DAQ with my distribution, most people won't have MAX, and I would like to make this as user friendly as possible. (generating port numbers from 0 - 31 behind the scenes is easy). Also VISA seems to be a process that must be opened and closed - I read in the Developer Zone that serial ports can be read in parallel if the serial read.VI is made reentrant. That may not be so for 32 VISA references existing simultaneously.
I am leaning to not using VISA but it seems that NI is no longer supporting the older Serial port VIs (?)
Let me ask you this- if I make a serial read VI reentrant, do I ne
ed to do the subVIs as well? or just the top most level where the reentrant calls will be made?
I realize a FOR loop would normally be the way to go, rather than have 32 copies of the same VI in a diagram, but 32 sequential reads would take way longer than 32 simultaneous reads.
Does my reasoning sound valid?
Are there other concerns that I am not aware of? (like why is NI no longer supporting the serial read VIs?)
The top level VI is called "reentrant SerialReadDrvr.vi"
Thanx for your time
lmd2
Lawrence M. David Jr.
Certified LabVIEW Architect
cell: 516.819.9711
http://www.aleconsultants.com
larry@aleconsultants.com
0 Kudos
Message 3 of 8
(4,474 Views)
Hi lmd2,

We encourage people to use VISA as it is a better technology, and the older serial driver is no longer being updated and worked on. The old vi's are still there in the compatability section.

I would recommend not going with the reentrant serial vi's as this would be much more complicated than the visa equivalent. For visa all you need to do is create the session to encapsulate the port. You could for instance open all the ports in a loop and pass the refnums all on as an array.

After all the sessions are open you can handle the reads in whatever fashion you prefer.

Lastly I should mention that MAX should come with NI-VISA.

Hope this helps out lmd2!

Best Regards,
Aaron K.
Application Engineer
National Instrumen
ts
0 Kudos
Message 4 of 8
(4,474 Views)
Well, this sounds OK, except ..."You could for instance open all the ports in a loop and pass the refnums all on as an array."
The problem is VISA constants are system dependant. If I distribute an EXE to 20 people, one may have two ports, someone else 6, or 20, or 30.From within an EXE how do I probe the OS to find what ports are configured. Even if I have the end user enter the available ports on his system on some screen, and I store this value to a setup file, how do I change a list of com1, com2, ... into VISA constants so that I can "open all the ports in a loop and pass the refnums all on as an array"?
Lawrence M. David Jr.
Certified LabVIEW Architect
cell: 516.819.9711
http://www.aleconsultants.com
larry@aleconsultants.com
0 Kudos
Message 5 of 8
(4,474 Views)
Hi again lmd,

While the VISA resources may not be well constant, this should not be a problem. You can use the VISA Find Resource vi to enumerate the system makeup. Check it out. I would suggest you use a query string like ASRL[0-9]*::?*INSTR (this was taken from the help file) to enumerate all serial ports on the pc.

Does this help?

Best Regards,
Aaron K.
Application Engineer
National Instruments
0 Kudos
Message 6 of 8
(4,474 Views)
Here is a simple VI that lists the serial ports on a given system, along with their description. I am attaching a version for both LabVIEW 6i and 6.1, since you didn't mention your version.

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
Download All
Message 7 of 8
(4,474 Views)
I have written 2 Labview VIs that might help.  One finds all the Comm ports for your machine, the other checks one Comm port number at a time for availability.  Hope this helps.
0 Kudos
Message 8 of 8
(4,275 Views)