LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Optimizing serial buffer read speed

In my program I am sequentially grabbing 69 bytes from the serial at 38400 baud rate.

However, the rate at which my VI is grabbing the data is too slow. Are there any methods of making it faster, assuming that I cannot use a high speed serial?
0 Kudos
Message 1 of 4
(2,774 Views)
Wire the "Timeout" input with 100 msec or even less to the serial port config VI. The default is 10 seconds if no data is presented at the port. While reading, use "Bytes at Port" to get the total # of bytes available and then use "VISA Read" to grab them. The "VISA Read" should be skipped if "Bytes at Port" returns 0.

Oh, don't forget to put some delay between each read. At such speed 38400, 100 msec should be fine.

Joe
0 Kudos
Message 2 of 4
(2,774 Views)
If you aren't using VISA (e.g., using the pre-LV 7.0 "serpdrv" VIs), then I suggest using VISA to improve performance.

If you are using VISA, you might also consider right clicking on your VISA Read function and selecting "Do I/O Synchronously". This optimizes for your situation--where you are reading a small piece of data at a high rate of speed and you know that the data will be there.

On the other hand, doing I/O asynchronously is preferred if you are reading larger blocks, or you don't know when your data will arrive, or you are using slow baud rates.

I hope this helps.

Brian
0 Kudos
Message 3 of 4
(2,774 Views)
Since I am making use of a carraige return to grab all bytes I need from the buffer, I am not certain if "Timeout" or grabing only "Bytes at port" will make any difference.

Could you please explain in more detail why putting a delay between each read will be beneficial? Write now, I am continously reading everything from the buffer, without using any loops. I assumed this would be the fastest way, because I am reading from the buffer as fast as it is being refreshed.
0 Kudos
Message 4 of 4
(2,774 Views)