LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Read Different from Hyperterminal

I'm trying to communicate with a digital indicator through the serial port. Sending any character (or pressing a physical button on the hardware) acts as a request for data, and reading from the port should give a string like this: "01A-0012.753". (the "01A" is fixed, the rest is the value I'm looking for, -12.753).

When using Hyperterminal, everything acts as expected. Using LabVIEW, however, sending works fine, but instead of returning the above string, I get 39 bytes which look like garbage as a regular string, in hex they look like this:
"0080 7800 FF80 7800 0078 1E78 E000 8000 8078 00FF 8080 8080 0878 E0F8 F880 781E 80F8 8080 78FE 00"

I am using VISA Write and Read, I've even set up VISA Configure Serial Port with
the same settings as documentation and hyperterminal.

(BTW, I say sending works fine, because I check the bytes at serial port. Before the send there are zero, afterwards 39.)

Any ideas what might be giving me the problem? Thanks!
0 Kudos
Message 1 of 5
(2,996 Views)
Could it be that your baud rate setting in the LabVIEW program is set four times too fast? (clues: you get about 4x too much data and most of it is in clusters of 4 equal bytes).

Check your communication settings and maybe try different speeds. Remember that Hyperterminal has a problem changing baud rates, e.g. if you change the baud rate in hyperterminal, they won't take efect until you disconnect/reconnect so you might actually not communicate at the rate you think you are.

Also make sure that the serial speed is actually wired to the "Visa configure serial port", maybe the wire is missing.
0 Kudos
Message 2 of 5
(2,996 Views)
This is a good answer; I don't know of any issues where data gets corrupted somewhere between the VISA and Windows Serial API layers so there has to be some difference in settings.

Check the baud rate, data bits, etc. I assume that you're using the exact same setup as far as cable, computer, port, and so on.

If this is still a problem make sure that you have the latest version of VISA, or at a minimum tell me what your VISA version is so that I can look into it further. Have you tried using VISA interactive control to do the basic read/write operations? You can access this in Measurement and Automation Explorer under Tools...NI VISA...Visa Interactive Control.

Also, I would like to make sure that you're using the shipping example of LabVIEW <->
Serial.vi.

Scott B.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(2,996 Views)
The problem is fixed now, although I still don't know what was wrong.

I updated the VISA version, but that did not solve the problem immediately. It seemed that just adding indicators changed the behavior somehow.

For example, when I was trying to read 13 bytes, it would read all the bytes at the port, until I wired an indicator to "return count" of the VISA Read vi. Once that was wired, it started enforcing the value on the "byte count" terminal.

Shrug, well it works now. Thanks!
0 Kudos
Message 4 of 5
(2,996 Views)
Asif,

Glad to know that you were successful, but I'm not sure exactly what went wrong in the first place. I tested this out and it seemed to work fine. With LabVIEW 7.1 and VISA 3.1 on Windows XP, I used a loopback connector and our Basic Serial example to test this out. I wrote 20 bytes to the port, then asked for 13 back on the read with nothing wired to the "return count" terminal. I was using COM1, 9600, 8N1, No flow Control.

The read returned the 13 bytes without a problem.

Scott B.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(2,996 Views)