LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Yet another communication difference between hyperterminal and LabVIEW

 

 

I'm trying to communicate with a Hart 1502 temp meter.  It's easy and works with an interactive terminal (PuTTY, in serial mode) but does not work with LabVIEW.  Well, as far as I know, the meter works fine but something is subtly different about the communications and I hope someone here can shed some light.

 

Basically, when I send "t\n" it returns a temperature and some other stuff.

 

I've been using the same serial-port VIs for a while and have had success connecting to a variety of other hardware.

 

Things I've tried:

 

0. Got out a DMM and checked the cable

1. Checked, re-check, re-re-checked the serial settings of the device.  This includes rate, data bits, parity, stop bits, and hardware control.

2. The termination character from the meter is CR or CR+LF.  I've set to CR+LF and set the VISA init function so.

3. I've tried sending "t\n" and "t" followed by "\n" in case the meter is confused by line-by-line input instead of character-by-character input.  Shouldn't be a problem but it was suggested elsewhere so I tried it.

4. Re-starting the computer, in case of some unlikely VIAS issue

5. Used a co-worker's set of VIs for opening the port.  Same issue.

6. Turned full-duplex on.  At first, I observed only the echo of my "t" transmission but nothing else.  Also, turned it off.

 

Does anyone know what's going on here?  Even if you don't know, give me a homework assignment that could illuminate the situation.

 

I'm using the init, close, and first read-until-expected-string functions in the attached library.

0 Kudos
Message 1 of 9
(1,642 Views)
The VISA Configure Serial Port does nothing to append termination characters for a write unless you modified it and you cannot modify it to automatically append two characters. You have to manually append the \r\n. Be sure the string control/constant is set for \ Codes Display.

I have not looked at your code - posting from my phone.
0 Kudos
Message 2 of 9
(1,632 Views)

Sorry, I can't se your code but sometimes its not what you send out that is problem but what instrument sends back.

 

Can you set up your code to just listen for characters maybe?

I think this can be done by sending en empty string to the write function and then using the read function to see if anything is in the buffer and just let it loop while building the response (if any).

 

 

If for example the device sends a string and more than one lf character

this could be a problem. Try disabling the termination char function and see if you can get visa to just display what if anything is in the buffer.

 

Hope this helps.

 

0 Kudos
Message 3 of 9
(1,629 Views)

I forgot to say you could also use MAX to work with the serial  port more directly..

0 Kudos
Message 4 of 9
(1,623 Views)

Hello k15n1,

 

I'd suggest taking a step back and using the Basic Serial Write and Read example that ships with LabVIEW (Help>>Examples). 

 

The function you indicated you were using appears to be looking for a very specific string (I believe you're using SerialPort_ReadUntilExpectedStringRecvd.vi), so if the instrument is returning something slightly different, you may not receive it. By default it's looking for "Hit any key to stop autoboot:"- are you providing a termination character or something instead of this?  It's difficult to tell without being able to see the VI you're using that calls these functions.  Either way, using the basic shipping example should give you a better idea of what, if anything, is being returned by the hardware.

 

Regards,

Tom L.
0 Kudos
Message 5 of 9
(1,618 Views)

@k15n1 wrote:

 

3. I've tried sending "t\n" and "t" followed by "\n" in case the meter is confused by line-by-line input instead of character-by-character input.  Shouldn't be a problem but it was suggested elsewhere so I tried it.


As Dennis eluded to, make sure your string control/constant is set to use the "\ codes" display.  It is in the right-click menu.  Otherwise you are just appending the actual characters '\' and 'n', not the CR+LF you are looking for.  Or just use the End Of Line Constant and Concatinate Strings to append the CR+LF to the end of your command.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9
(1,609 Views)

Or just use the End Of Line Constant and Concatinate Strings to append the CR+LF to the end of your command.  

 

Windows only for that trick. be careful if you have a MAC or Linux machine


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 9
(1,605 Views)

 

I did not realize that my terminal program was sending \r\n.  I was only sending \n in my labview code.

0 Kudos
Message 8 of 9
(1,588 Views)

As suggested, I used the basic serial read/write VI from the help files.  There was some weird behavior but at least it was receiving about the right amount of data.  I fiddled with echo settings on the meter and turned off the "Enable Termination Character".  A combination of these settings and adding \r to the transmission side of things fixed the problem. 

 

Thanks for all the help with this problem!

0 Kudos
Message 9 of 9
(1,585 Views)