Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

USB to RS232 Adapter: VISA Serial Write Works but VISA Serial Read Gets Timeout Error

Hey Everyone,

 

I am fairly new to LabVIEW so bare please bare with me. I am trying to receive data from a C0-08TD1 PLC that is connected to my PC via USB to RS232 adapter. The Baud Rate = 38400, parity = Odd, stop bit = 1, and data length = 8-bits (given to me when I connect the PLC to the CLICK PLC programming software). I am able to perform VISA serial write, however with VISA serial read I receive the " VISA: (Hex 0xBFFF0015) Timeout expired before operation was completed " error message. I learned this occurs by single stepping through the entire program. This appears to be the ONLY thing going wrong within the vi. 

 

Here is an image of where the Serial Read give me an error (one of my sub vi)

Serial_Command_VI.png

 

I have attached the main vi I am using, as well as the two sub vi inside of the main. So my two questions are: 

1. Is it possible for me to receive information from my PLC this way?

2. If so, what could I be doing wrong?

 

I would like to note that a majority of the content in these vi were created by an old coworker. He had it all up and running previously on his PC, and now I am trying to get it to work on my PC.

 

Thank you to everyone who read this post.

0 Kudos
Message 1 of 5
(2,698 Views)

Hi

I don't see any vi's attached, but I'm missing the serial initialize vi and what the message is that you are expecting.

Is it indeed 13 characters or less, is there and end character defined and used? (that is why I like to see the initialize)

Just some questions to be able to help.

greetings from the Netherlands
0 Kudos
Message 2 of 5
(2,688 Views)

Albert.Geven

 

Thanks for replying to my post! I do not know why they didn't attach. Let me try attaching them to this post.

 

I have a serial port configuration vi that feeds into the sub vi that you see in the image in my first post. However I am not sure what I am expecting to see out. This was the vi provided by my old coworker.

 

It is indeed 13 characters because the count that is returned from the write function is 13. Prior to this, that value was set to 1000, and I am not sure why. I thought maybe I was getting the timeout error because the byte count was too high, so I stuck that "count amount" there to see what was coming out from the serial write and fed that number to my byte count for the serial read vi (not sure if that is the correct thing to do?). 

 

I have looked around to see if I could find an end character for the PLCs, but I have not been able to see anything. Maybe it would make more sense for me to disable the termination char at the serial port configuration (located in main vi)?

Download All
0 Kudos
Message 3 of 5
(2,679 Views)

Hi

A few more questions and maybe a temporary solution just to find out what is reported back.

The first question: Why are you repeating the send command 5 times in a row?

Second question: why use a timed loop in a slow system

Why are you using 13 (the number of characters you send) instead of something you expect.

 

But try the following code only to test what you get back. Don't use this in production code.

The most important reason is that Bytes at port is a much used function that depends on timing instead of a real handshake. If the end character is known it delivers a real handshake and I suppose it is a CR because that is used in initialize.

 

Look at the resultant string and determine if it is used in the old software anyway. Maybe there is no communication returned and that may be the reason the command is repeated 5 times to be sure the relay is set.

 

Good luck

greetings from the Netherlands
Message 4 of 5
(2,665 Views)

Hey Albert.Geven,

 

Thanks for the information! However, I learned I was using these vi incorrectly so I apologize. I had a feeling this was the case, otherwise I wouldn't have been running into all of these errors. Thank you for trying to help me troubleshoot the problem. 

 

Best Regards

0 Kudos
Message 5 of 5
(2,659 Views)