Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Port Timeout Problem with Labview

I have a device that I can communicate using hyperterminal program via RS232 serial port.

But I could never be able to get the same outputs using Labview's Advanced Serial Write and Read VI.

I always get the timeout errors. (The timeout error comes from the device itself not from the VI) 

The command I send to the device using hyperterminal window is

 

:##000 PGGIV##

 

The output that I get is 

 

:330000 00 PGGIV 22956 19013 23467 24910 24939 2501442

 

which is the output I want.

 

I have to copy and paste the command to the hyperterminal windows in order not to be timed out.

 

But I could not figure out what are the correct settings (such as "input buffer size", "termination char", "timeout", "bytes to read", etc) that I should put into the the VI.

 

I am a machanical designer and I don't understand too much about these kind of issues.

 

Can anyone help me out ?

Thanks

 

 

 

0 Kudos
Message 1 of 3
(6,686 Views)

Hey Ozkan,

 

So as you may know, serial communication needs certain parameters to actually occur.  When setting up your hyperterminal connection, you had to specifiy parameters such as Bits per second (baud rate), Data bits (number of bits will be sent), Parity (determines whether an odd or even number of 1s will be in the data), Stop bits, and Flow control.  These are the most common, and typically the most important parameters to be set.  Your Advanced Serial Write and Read.vi will need to reflect these settings in Hyperterminal that were working for you.

 

In your devices documentation you can find all of these settings and also, if any termination character should be used (but more likely it's none because you would have to type in a termination character in Hyperterminal as well).

As for Bytes to Read, you should specify this value as the expected size (in bytes) of the returned string you expect. If this is too small, your returned string will be truncated, if it is too large, you will return your whole string but the indicator of Bytes Read will not made the Bytes to Read control.

The Timeout control should be set to match the timeout your hardware is designed for.

As for the Input Buffer Size, this is just the allocated memory set aside for the communication to occur, if this is too small, you'll obviously get an error, but if it's the right size everyting will work appropriately.  Going over the expected size is not a problem as it's just unused space so don't worry too much about this number unless you get a memory error.

 

To avoid running into all of this extraneous configuration, you may want to look at using the Basic Serial Write and Read.vi.  It's more similar to Hyperterminal inoperation because of its configuration options.  Let me know what results you get from trying this VI.

 

David Pratt
Group Manager for Application Engineering Specialists | Automated Test
NIC
0 Kudos
Message 2 of 3
(6,666 Views)

Hello David,

Thanks for the reply.

I found out that it is a termination character problem.

I added \r\n to the end of my command and I used Basic Serial Write and Read VI and it worked.

I am reading the same output that I get using the hyperterminal window.

Thanks again

 

0 Kudos
Message 3 of 3
(6,656 Views)