Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
1 ratings:
 4 out of 5     Rate this Document

Preventing LabVIEW from Continuously Polling the Serial Port

Primary Software: LabVIEW Development Systems>>Professional Development System
Primary Software Version: 8.0
Primary Software Fixed Version: 8.0
Secondary Software: N/A
Hardware: Serial>>RS-232

Problem:
When I read from my serial port, LabVIEW continuously polls for data until the data is available on the port. This increases my processor and resource usage and prevents other loops in my program from executing smoothly. How can I prevent this?

Solution:
This issue can be resolved by using VISA events. A VISA event can be generated when a serial character arrives at the port using the VISA Enable Event function. Within a while loop, you can then place a VISA Wait on Event function before the VISA Read function.

The VISA Read will be executed only when a character is received at the serial port. Until the data arrives at the serial port, the thread containing the VISA Wait on Event function is suspended. Therefore, the VISA Read function is executed only when data is available at the port. By specifying the number of bytes to read as 1, you ensure that the serial port is polled only when data is available. Before the program stops, a Disable VISA Events function should be used.

These functions can be found in LabVIEW on the block diagram functions palette by browsing to: Instrument I/O»VISA»VISA Advanced»Event Handling.

For more information on the VISA Wait on Event function, refer to the LabVIEW Help.

Related Links:

Attachments:





Report Date: 09/15/2006
Last Updated: 09/20/2007
Document ID: 41E45O37

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit