Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

rs-232 communication

We�d like to connect our laptop to a biomedical device and create an interface using LabVIEW. This is a RS 232 protocol for which a train of data is sent automaticcally each 5 seconds from the device.
I�ve written a VI who is able to read these data and to display a part of them.
My problem is that my VI does not display the entire train of data, it seems that it is divided in 2 parts (compared with the data I�ve seen using the hyper-terminal).
0 Kudos
Message 1 of 29
(6,022 Views)
Hello,

I am not sure I understand exactly what you are seeing vs what you would like to see as far as data concerned, however, here are the players involved with serial reads:

Your read operation will terminate on one of 3 conditions, whichever occurs first:

- you receive the number of bytes specified to the read function

- you receive a termination character (and you have termination enabled)

- you receive a timeout error due to the amount of time specified for the timeout having expired before the other two above noted conditions occurred.


In general you have flexibility in reading data received over the serial port. The UART (a part of your serial port) takes care of receiving the data and the OS (and LabVIEW) takes care of getting that data into memory accessible by LabVIEW. So your data will be sitting in local memory on your computer waiting for you to read after it has been sent. You can then read it based on the 3 conditions above. That is, if you expect to receive a block of data, and then a termiation character, you can read a large number of bytes and your read will stop when it sees the termination character. In this case, if your data is sent in binary form you'll need to be weary of the possibility that one of the bytes sent for data may be the ascii equivalent of your termination character; this could cause you to stop reading a block of data prematurely. On the other hand, if you know you are receiving a block of data of a given size, then you can simply read the specified number of bytes you know you will receive (and even disable termination to remove the possibility of an accidental termination as discussed above).

It sounds like you are encountering a problem described by the behavior noted above. Hopefully applying the noted ideas will enable you to get your data more easily!

Repost if you are still having trouble and be sure to be as specific as possible about the format of the data you are trying to receive.

Best Regards,

JLS
Best,
JLS
Sixclear
Message 2 of 29
(6,019 Views)
Thanks for your help.
actually i just want to read the entire data and then extract a part of it.
Maybe there is a difference between what is recorded and what is diplayed but in my VI i use a specific number of bytes - that is why i don't understand why sometimes the data is not diplayed entirely.
However i am going to check my VI using your comments.
Thanks again,
gt
0 Kudos
Message 3 of 29
(6,019 Views)
Hello,

Just a quick update: you may not actually see all of the characters that you receive since some may not be visible (such as the space, tab, linefeed, carriage return, etc) and others are not printable in which case you'll see a little box in LabVIEW. To see the underlying ascii representation of the character you can right click on a string indicator in a LAbVIEW front panel and select codes display or hex display.

Repost if you are still having trouble!

JLS
Best,
JLS
Sixclear
0 Kudos
Message 4 of 29
(6,019 Views)
After a few modifications, everything seems to work pretty well.
thanks again
gt
0 Kudos
Message 5 of 29
(6,019 Views)
Great, feel free to repost if you encounter any issues as you proceed!

JLS
Best,
JLS
Sixclear
0 Kudos
Message 6 of 29
(6,019 Views)
Hope I am not disturbing some comminication but it is very releated what I am tring to do. I have 6514 electrometer to make a current measurements. Having no board and I am trying to use the rs-232 to comminicte with instrument. Please helpme to write a Labview VI for this purpose. I am able to modify if I have some similar VIs. Thanks.

S. Saygi
0 Kudos
Message 7 of 29
(5,878 Views)
Hello,

There is an IVI driver for your device which you can download at the following location. You will need to install the IVI compliance package as well; instructions and corresponding links are at the driver download page (you will need to create or enter NI Profile information before the actual download site will be exposed. You should be able to start here, where if you need to enter or create such information, you'll be linked to the driver thereafer:

http://sine.ni.com/apps/we/niid_web_display.download_page?p_id_guid=E3B19B3E90A9659CE034080020E74861

This will give you a friendly API for communicating with your instrument!

Best Regards,

JLS

PS - if you only need limited functionality from the instrument, you can use simple NI-VISA calls to directly write to and read from your instrument instead; the appropriate commands should be in the user manual for the instrument.
Best,
JLS
Sixclear
0 Kudos
Message 8 of 29
(5,866 Views)
Thanks, I got the all drivers. My poor VI is following. Rigth now trying to save the data and display it into front panel. Can you help me to to this? The data will be chart/graph, data vs time and saving in ASCII. I am using rs-232 and VI takes reading from buffer of instrument. Some easy part is left but ı am a little confused on this.

ssalih
0 Kudos
Message 9 of 29
(5,830 Views)
Hello,

Probably the easiest way to read your serial data in, store it, and then retrieve and display it is to read the data and format it to be a spreadsheet string (a big comma or tab delimited string; you can write to the file every so often and not store an enormous string if you'd like, but the file will be just data and tabs, for example). You can do this easily using the string concatenation funtion to put tabs, for example, between your data points. Then, when you read it back you can use the "spreadsheet string to array" function and it will take your data (now in spreadsheet string form) and produce the array which contains those data points. You can then wire this directly to a LAbVIEW native graph 🙂 Of course, the file I/O interface will do the file opening, writing, reading, and closing for you, where you are only writing and reading strings, and you only need to open and close the file once for a given run of your program, where you can perform the necessary writes for example in a loop!

That should get you your desired functionality with not too much code!

Best Regards,

JLS

PS - you could also convert and store the data in binary form and retreive it that way, but unless you are really concerned with memory and will write TONS of data, I don't think you need worry about that.
Best,
JLS
Sixclear
Message 10 of 29
(5,810 Views)