LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial read problems

Hello,

I'm trying to read data continuously from a PLC using labview, and all the information I have consists of the data rate, bits, and parity. This is all set correctly. It also mentions that a carriage return and line feed separate each group of readings. I don�t believe it supports flow control?

I'm using the advanced serial read/write example, and when I go to read, it runs fine, and I set the read bytes to 40 (the actual bytes counter says 40), I get the datastream of what I�ve expected, but after a while it times out, and I can't connect again until I reboot. I've tried changing the buffer size, which helps temporarily, but still no avail.

All I'd like it to do is just continuously read the data, and separate it. My assumption is
that I need to clear the buffer? Any help would be great, TIA.
0 Kudos
Message 1 of 13
(3,794 Views)
Instead of trying with a fixed byte count, try using a VISA Bytes at Serial Port to determine how bytes are actually available and then use that number in your VISA Read.
0 Kudos
Message 2 of 13
(3,794 Views)
Welcome to the world of serial port black magic! There is always something out there which is not as the documentation says or the documentation is incomplete or ambiguous. Much trial and error is common.

Try reading Bytes at Serial port and then request that number of bytes from the Read function. This way things don't hang up waiting for bytes that never show up. Also check to see what characters the read function uses for end-of-line or end-of-message to make sure that it is not getting confused.

Lynn
0 Kudos
Message 3 of 13
(3,794 Views)
I hate to answer a question with a question, but to be of any help, we will need to know the brand/model of the PLC you are trying to read. It is highly unlikely that you will be able to get any usefull information directly out of the cpu port without some intermediate software to format your sends/recieved data to and from the PLC proprietary format. In general, the easiest way is to use an OPC server that supports the PLC you are using. If you wish, you can pass some more info, and some of us may be able to help you.

Good luck

Dave
Message 4 of 13
(3,794 Views)
well basically what all i really need it to do is recieve data and parse it (not too worried about that) and when the device goes idle, the program should go idle as well, and when the plc starts sending data again, the program wakes and goes back to work.

just not sure about getting around that timeout issue (yes i have had a gander at the detect break example)
0 Kudos
Message 5 of 13
(3,794 Views)
Hi,

If your PLC sends a termination character, the best way is to use VISA and configure the communication so that the serial read is terminated by this termination character (Can be set using property nodes "Termcharen" and so on).

This way each read will automatically return one message, regardless of how you wire the "bytes to read" terminal. I use this functionality all the time and find it by far the most convenient, provided the PLC does actually send a Termination character.

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 6 of 13
(3,794 Views)
alright, but how do i deal with the idle time, when the plc is not transmitting? I don't want the connection to time out (then i can't reconnect to the port without rebooting)
0 Kudos
Message 7 of 13
(3,794 Views)
also, the plc in question is a direct logic 06
0 Kudos
Message 8 of 13
(3,794 Views)
Now that we know you are using a DL-06, I can offer some specific advice. Automation Direct offers an OPC server called DS Data32. I have used this several times, and it will do all you have asked and much more. From what you have said, I am not sure that you have considered how to decode the serial data from the PLC, even if you could read the raw data. Just connecting to the serial port of a PLC will not cause the PLC to send data. The PLC must be polled by an external device (usually a PC based device) to cause it to send data. That is a major function of the OPC server. You simply define the data in the PLC that you wish to recieve in the OPC server setup, then talk to the OPC server with Labview (with Datasocket).

Good luck

Dave
Message 9 of 13
(3,794 Views)
The plc has been pre-programmed to send data out the serial port while in operation. When someone uses the equipment, it sends it in a format: (P0103 L4000 C0010) with a line feed & carrage return at the end of the string. I am trying to capture this packet, and when the device goes idle, the plc stops sending data. I would like to resume capturing data when the plc starts sending again.
0 Kudos
Message 10 of 13
(3,588 Views)