Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

I can't read Serial Port with Labview.

Solved!
Go to solution

I try to study serial port example  form this link http://www.youtube.com/watch?v=T9sgAyjb-Kk& . I do anything like example unless Chart History Lengh. because I don't know how to open Chart History Lengh and I'm not sure this is invoke with my program. when I run my program it can Write to serial port  but can't Read from serial port. It show this error behide the Read Block.


Error -1073807339 occurred at VISA Read in test_serial_port.vi

Possible reason(s):

VISA:  (Hex 0xBFFF0015) Timeout expired before operation completed.

 

I don't know why it error. And when I wire from Scan from srting to the Waveform Graph.It can't connect although same variable.

0 Kudos
Message 1 of 7
(6,364 Views)

Try first configuring in MAX. Perform serial loopback test in MAX. Follow the instructions in the link below. Also prefer changing number count on read tab to 6. This should work!

http://zone.ni.com/devzone/cda/tut/p/id/3450#toc3

 

 

0 Kudos
Message 2 of 7
(6,363 Views)

are you sure your cable is OK?

greetings from the Netherlands
0 Kudos
Message 3 of 7
(6,360 Views)

You were also having problems with serial port reading back in January of last year. What have you done since then?

 

Your most likely issue is a termination issue. VISA Read needs to know when to stop reading. If you configured your VISA session so that termination is enabled, then VISA Read will read until it sees the termination character (also set via the VISA Configure Serial Port), or it reaches the number of bytes you've supplied to the "bytes to read" input. If you specify the wrong termination character, and you've wired a large number to the bytes to read input, and there's less bytes on the port (but the last byte is the termination character), then you will get a timeout error. You need to look at the documentation for the device you are trying to talk to to see what it uses as the termination character.

 

Have you checked to see if there are drivers in the Instrument Driver Network?

 

 

I have no idea what you are asking about as far as the Chart History Length. Are you asking how to change it? Have you looked at the help for that ?

0 Kudos
Message 4 of 7
(6,338 Views)

I try to create RS232 plug loop back like this http://zone.ni.com/devzone/cda/tut/p/id/3450#toc3. In the picture RS232 pin1 on the right of plug but in real RS232 pin 1 on the left of plug  I think it should connect cable like my picture. but when I run it show same error.

0 Kudos
Message 5 of 7
(6,325 Views)
Solution
Accepted by topic author mmc01

Did you read my response? You're only sending out one character (the character "1"). Thus, a loopback would feed it back onto the receive line, and the buffer would have 1 character. Not 200, which is what you have VISA Read set to read. The default setup for the serial port is to have termination enabled, and to use the linefeed character as the termination character. Look at the Help file for VISA Configure Serial Port. It's quite clear. This means that VISA Read will keep reading until (a) it reads the amount of bytes you told it to read, or (B) it sees the termination character. So, in your case since you are not turning off the termination character, and wiring 200 to the VISA Read, VISA Read will keep trying to read until it (a) reads 200 bytes, or (b) it sees the termination character. Neither of these is going to happen, so VISA Read times out because (a) it never gets 200 bytes, and (b) it never sees the termination character.

Message 6 of 7
(6,318 Views)

And doing a loopback test is almost always a waste of time. I can count on one hand the number of times I've had a bad serial port.

 

 

Most of the time, the reason for a timeout is a bad write. You have either the wrong cable, the wrong com settings, you are sending the wrong command, or you are sending the command without the correct termination character. Attach the instrument manual so someone can see what is supposed to be sent compared to what you are actually doing.

0 Kudos
Message 7 of 7
(6,314 Views)