LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

0 bytes on VISA Read?

Hi All,
 
I'm trying to talk to an ultrasonic anemometer via the serial port.  My problem comes up when I try to poll the instrument for an individual reading.
 
Here is how the instrument works using hyperteminal:
  type "?S" and you immediately get a 37 character data string back from the instrument.
 
So in LabVIEW, I use a VISA Write to send the "?S" followed by a VISA Read of 37 characters.   A query of the com channel says 0 bytes at the port (after the VWrite) even tho in hyperteminal 37 chars immediately come back when the poll string is sent.  (Using the example Basic Serial Write and Read.vi with the delay portion cut out)
 
Am I missing a buffer setting or something here?  Oh yeah, WinXP LV 8.2.1
Greg Cole
“It is not the ship so much as the skillful sailing that ensures the prosperous voyage.”
0 Kudos
Message 1 of 14
(3,538 Views)
Hey Greg,
 
The problem could lie in the termination character.  Hyperterminal has a default termination character in the program.
 
Check your program manual or you can simply guess and check which termination character works for your instrument.  Try using \n or \r as term characters, they should fix your problem.
 
Regards,

 

 

Message 2 of 14
(3,527 Views)
Did you include the \r\n control codes that are in the default string to write? Those are the codes for CR and LF. They are sent in Hyperterminal when you press the enter key.
Message 3 of 14
(3,525 Views)
Two things come to mind: 1. You might need a slight delay after sending the "?S" command, say 10 msec before you can read your 37 characters. 2. You might need to concantenate a line feed and/or carriage return character after the ?S. And you might need to do both.
PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 4 of 14
(3,517 Views)
Greg,

Does the device require a carriage rerturn or some other termination character? LabVIEW does not automatically add those while some terminal emulation programs do. To add the carriage return you can use the carriage return constant and the concatenate strings node or change the string control in which you type your commands to the '\' Display mode.

Lynn
Message 5 of 14
(3,517 Views)

Hmmmm...

4 replies in eight minutes and they all suspect the termination character.

I would try adding a term char if I were you. Smiley Wink

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 14
(3,507 Views)

Wow... fast responses indeed!

OK, to address the issues brought up.

1.  Some commands require the \r\n appended when sent to the instrument.  However, the poll query does not.  As soon as i type the second char in the poll string I get a reply (in hyperterminal).

2.  Termination char: The return data string has an <ETX> (ascii 3) followed by a checksum.  That dinna work.  I also tried \n (ascii 10) and \r (ascii 13) and those dinna work.  A cut and paste from hyperterminal and conversion to hex show all strings terminated with 0A which is ascii 10.

I think there is something about the immediate response nature of this.  The instrument also has a continuous mode, where upon exiting configuration mode it sends a 37 char data packet once a second.  I was able to read that fine.  It is when I am in polled mode that I hit this wall.  Send two chars, 37 immediately back but showing as zero in LabVIEW...

I appreciate the quick replies!

Greg Cole
“It is not the ship so much as the skillful sailing that ensures the prosperous voyage.”
0 Kudos
Message 7 of 14
(3,492 Views)

HI Greg,

I am not sure if I follow your follow-up.

It sounds like some command work with CR.

You also mentioned ETX and a checksum.

I seem to rember instruments that would go into "spew mode" and would stop when they saw "any character". How about making sur ethe port is inititalized to NOT use the term character and you do the CR when appropriate.

Could you post screen shots of the commnads that work (in slash code format) and those that do not?

The other thought (that is way out there) is the parity. If the commands that work are all even and parity is even, then they would work while the commands with odd characters would look bad due to a lack of parity bit.

I hope some of these ideas get you closer to a solution!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 14
(3,475 Views)

OK.  I'll explain the sequence as it goes in hyperterminal (with '\' view and line #'s added for reference):

1 D3\n
2 current\sconfiguration\s:\n
3 P1\sG1\sM3\sU1\sB5\sF1\sT1\sS7\sC1\sI1\sA2\sNS\sO1\n
4 D3\n
5 Q\n
6 Q\n
7 \s\02S,-000.07,-000.06,+000.06,M,00,\032C\n
8 \02S,-000.06,+000.01,+000.06,M,00,\032C\n
9 \02S,-000.06,+000.01,+000.02,M,00,\0328\n

1.  I type D3 and hit ENTER
2, 3 and 4 get sent back.
5  I type Q and hit ENTER  (exits config mode, goes to poll mode)
6 gets sent back
7 I type ?S  (note these two chars are not echoed back but data string comes back immediately, no ENTER press required)
8 I type ?S (not echoed, get data string back, no ENTER pressed)
9 et cetera

If I set the device into poll mode in hypertermal then close and move to LabVIEW, I use VISA Write to send ?S but never get any bytes back on VISA Read (times out) and a check on COM1 before I do the read it says: Bytes at Port = 0.

I've also tried placing the Visa read and write in parallel.  The idea being I have a loop whipping along checking the port for any data, if any bytes found do a Visa read.  With that up and running I do a Visa Write of ?S.  The idea was if the data was coming so fast my read was missing it, but even in that config no bytes are ever detected at the port.

Thanks for any input!  I'm about ready to get the cure-all sledge hammer out.

Greg Cole
“It is not the ship so much as the skillful sailing that ensures the prosperous voyage.”
0 Kudos
Message 9 of 14
(3,459 Views)

Ok Greg,

How about the configuration?

Did dyou verify the com port is configured for no term character?

Parity?

NI-Spy may also help confirm you are send what you think you are sending.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 14
(3,456 Views)