LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To read 512 bytes using serial communication

I want to read 512 bytes of data using rs 232 with the timeout of 30ms. I am using "Serial read with timeout -Palm.vi". Is there a limitation of the number of bytes I can specify to this VI?
Thanks!!
0 Kudos
Message 1 of 4
(3,005 Views)
Hi software enigineer,

It is not possible to transfer 512 bytes per 30 ms here. To do this would require a baud rate of 136533 (512*8/.03) and the maximum possible baud rate is 115000. The recommend baud rate for a serial transfer is 9600, which would mean transferring at most 36 bytes if the timeout is kept at 30ms. Moreover, there is usually some overhead involved in serial communication, and I would recommend sending a little less than the maximum 36 bytes every time too.

On another note, I noticed that in your block diagram, you are using the Bytes at Serial Port vi. Definitely use the output of this vi to determine how many bytes to read at a time and read the bytes as they become available in the serial buffer rather than reading in a large buffer
all at once. Continuously read and append the output until there are no more bytes to be read or until the termination character is read. This will avoid any lost data transmission due to overflow.

Good luck with your program!

Kileen Cheng
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,005 Views)
Hi! Kileen,
As you have recomended that the data from the serial port should be read in blocks rather than reading the whole data of 512 bytes at once....the problem is that the hardware returns the string in the format of "string,data1\n". The string is of two characters and "data1" is an array of 512 bytes and "\n" is the terminating character.
Seems to me that even on using Byte at Serial Port.vi will return 512 bytes to be read at one time. Any suggestion of handling such a situation.
After receiving the array of data1, I need to plot it on a graph.
TIA
0 Kudos
Message 3 of 4
(3,005 Views)
Hi Rachana,

Since data is being passed to your device 512 bytes at a time, the best idea in this situation is simply to slow down your data transfer rate. A recommended baud rate is 9600 and to achieve this rate with 512 bytes, a transfer would occur at a maximum of about .5 seconds. Otherwise, there is the potential of running into overflow errors and losing information in your buffer.

Best of luck with your application.

KileenC
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,005 Views)