LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion of VISA output to human readable string

Solved!
Go to solution

Hi,

 

I've been attempting to get output from a scale to show up in labview to no avail. When I connect to the scale via something like hyperterminal, I get output of the form:

...

+ 47.9942
+ 47.9973
+ 47.9973 g

...

 

yet, when I used the same settings in labview I get 

 

\00\00\00\10\AB\s\s48\AE\B0\B348\s\s\s\s\r\8A  -- if I use \ code display

or

48®°³48 (something like this) -- if I use normal display

 

It seems like I am not returning hex, as I think AB and AE are not actually hex characters. I based my vi on the builtin advanced serial write and read template, so I am not really sure as to what I am doing wrong.

 

Thanks in advance for any help.

0 Kudos
Message 1 of 19
(2,884 Views)

I suspect that your settings are not truly the same as Hyperterminal.

 

Also, why are you passing the data you read from the device to Flatten to String. It already is a string.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 19
(2,871 Views)

@Mark_Yedinak wrote:

I suspect that your settings are not truly the same as Hyperterminal.

 

Also, why are you passing the data you read from the device to Flatten to String. It already is a string.


Thanks for your help!

 

I've double checked the settings. 1200 baud, 8 data bits, no parity, 1 stop bit, no flow control... could it have to do with the xon and xoff characters I need to specify in the vi?

 

I passed the data to the Flatten to String before sending it to the display because otherwise I get \AB\s\s24\AE\B0\B04\B3\s\s\s\s\r\8A instead of something like \00\00\00\10\AB\s\s24\AE\B0\B04\B3\s\s\s\s\r\8A and I didn't know if the leading \00's were important.

0 Kudos
Message 3 of 19
(2,862 Views)

I would skip the flatten to string completely. Send only what your device is expecting. Hyperterminal is not sending the extra data. If you need flow control then you are not setting it in your initialization and therefore setting the XON/XOFF characters will have no effect.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 19
(2,859 Views)

I'm sorry if I was unclear. The problem I am having is not sending the data, but receiving the data. The VISA device is set to auto-print. All I am trying to do is read the output correctly.

 

So you think that the leading \00\00\00\10 that I lose if I do not flatten to string is of no consequence?

 

Thanks again.

0 Kudos
Message 5 of 19
(2,855 Views)

Your device is not expecting to see that infromation as part of it's command. Sending garbage to the device may result in garbage out. You should always make sure you send exactly what the device is expecting. If teh manual says to send "123" then don't send it "\00\00\00\03123" which is what the flatten to string will end up sending. By default flatten to string prepends the size of the data. Your device may not handle the extra correctly.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 19
(2,853 Views)

@Mark_Yedinak wrote:

Your device is not expecting to see that infromation as part of it's command. Sending garbage to the device may result in garbage out. You should always make sure you send exactly what the device is expecting. If teh manual says to send "123" then don't send it "\00\00\00\03123" which is what the flatten to string will end up sending. By default flatten to string prepends the size of the data. Your device may not handle the extra correctly.


I understand your point, but as I have the write boolean unchecked in my VI, I am not writing anything to the device. I am strictly trying to read the data that is being auto-printed by the device and can not seem to make it into something human formatted.  

 

I appreciate the assistance.

0 Kudos
Message 7 of 19
(2,848 Views)

Are you actually interpretting the data correctly? What does teh device documentation say regarding the format of the data it is sending? How do you coordinate each piece of data? Unless the data being sent is a single byte you need to make sure you are reading and interprettng the data correctly. If the data is 4 bytes long, are you reading the right four bytes?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 19
(2,843 Views)

I believe I am. The documentation I have tells me that I should be receiving 16 ASCII characters each time my device auto-prints, with the last two being a carriage return and then a line feed.

 

So if in my VI I set the "bytes to read" constant to 16, I am not sure why I am still not able to get human readable output from the string. I am reading the entire output from the device every time it outputs 16 characters. Am I just missing some fundamental concept here?

 

Thanks again! 

0 Kudos
Message 9 of 19
(2,824 Views)

If you set the 'End Read on termination character' to true, you can put in some arbitrary number (i.e. 100) for the bytes to read. Get rid of the Flatten to String and run the VI until you have data displayed. Then go to Edit>Make Current Values Default. Save the VI and attach it.

 

The fundamental concept is that with an instrument that sends a termination character, A VISA Read will automatically terminate when that character is detected.

 

It would also be extremely helpful if you could attach the manual. And, check to see what sort of terminal emulation mode is set in Hyperterminal. Hyperterminal is capable of emulating types of terminals and some of these terminal types embed codes that you would need to manually interpret in LabVIEW. You can also disable auto-detection of terminal type and select ANSI and see how the data is now being displayed.

0 Kudos
Message 10 of 19
(2,814 Views)