05-09-2015 11:52 AM
Hi Everyone!
I need help with the communication of RS232. The hardware which I have sends data continuously to the RS232 cable (The data is digitised). I need to plot these data with the help of LabVIEW coninuously. The VI file I have as of now, doesn't even receive data. I would be glad if someone could guide me as to where I am going wrong. I am attaching the VI files for the reference.
Regards,
Akriti
05-09-2015 12:10 PM
05-09-2015 12:18 PM
(Almost) every serial communication device is different -- it may use a different port, have a different Baud rate, use different handshaking, have its own command structure (what you send it to get it to send back to you), and have its own data structure (does the data come back as Binary, Ascii, etc.).
One way to just check that the communication is working is to fire up MAX, choose the COM port to which you think your device is connected, and open a Test Panel. You can there set various communication parameters, baud rate, parity, and so forth. You can also send and receive characters, with or without terminators (\r, \n), and ensure that you can get (some) two-way traffic.
Once you have this, I recommend duplicating the simplest aspects of this in a test LabVIEW program. For example, configure the selected COM port using the parameters that you determined seem to work. Send (using the same method you used in MAX, with or without terminators) a simple command, such as the "Identify yourself" command. Try to do a Read (either a fixed number of bytes, or a "lot" of bytes, depending on how you have things configured) and see whether or not you get anything (including an Error on the Error line) back.
If the simple code works, compare it with your more sophisticated code that you attached, and see where they differ. If it fails, post what MAX taught you about your device (including what you were able to send and what you were able to receive), and post your simplified (no loops, just straight sequential VISA functions to open, configure, write, read, status, and close the port) code, including telling us what happened.
Bob Schor
05-09-2015 02:29 PM
As mentioned already above, you need to know the serial ports settings and the format of the messages.
Some devices terminate the messages with one or more characters like CR,CR+LF, ETX (hex 0x03; end of text), etc.... Other devices may have predefined message structure without termination character, where you know exactly how many bytes to expect.
It is always a good idea to test the communication with some kind of terminal program, as Bob mentioned already. I use YAT :: Yet Another Terminal and am very happy with it. Particularly in your case, you said that the device sends data continuously, it is very easy to figure out with a terminal program if you have the proper communication settings since you just need to read from the device.
BTW, you need to remove the 'VISA Write' from the code. There is no need to send anything to the device if it sends constantly data. If the device terminates the message with a specific character(s) you don't need 'Byter at Port' at all. 'VISA Read' is all what you need and enabled 'End read on termination character?' including the proper character setting. Make the serial timeout short (maybe 200 ms) and ignore the timeout error, so that you can stop the loop without long delays, when the user clicks the stop button.