LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex String to Number to Array... I think...

Hello to the group,
 
Here's my dillemma...
I'm interested in a specific output from my device. The expected output is 256 values, as a row of 512 byte (Hex). To simplify communication, I used the LabVIEW Serial VI and added a terminal at the "Read String". This outputs a string (when displayed as "Hex Display") like 0200 0200 ... ... 0200 0100. I wired that output into the "String" input of a Hexidecimal String to Number conversion. Then, I am using a Build Array, wired into the single element. Finally, the appened array terminal is wired to the "Data Array" input of a VI which is designed to do a number of calculations on the output from the device.
 
When I run the program, I can probe the output from the LabVIEW Serial and though the window is filled with squares (Is there a way to display hex in a probe?) it appears to be passing 256 squares. Unfortunately, that's where the chain breaks, as the output from the Hexadecimal String to Number conversion remains a solitary 0 and the output of the calculations is NaN (see attached jpg. Read String is probe 26, 25 is the output from the conversion and 27 is the output of the calculation MSE).
 
Suggestions?
 
Cheers,
Stephen
0 Kudos
Message 1 of 2
(2,814 Views)
Hi Stephmon,

no jpegSmiley Surprised

but I see already one missing item, you get 256 values in 512 bytes. So your read Serial should read 512 characters. You can't see hex in the probe it only displays ASCII.
You shouldn't us the String to number, what this does is interpret the ASCII code for 0-F (0x30-0x39 and 0x41-0x46) and convert this. What you need is a data-conversion. (see attachment). This VI (unflatten from string.vi) has options about high-byte and low byte, you should make sure that the boolean option is false (not shown in attachment).

The documentation from the device should also give you a hint if you should use a U16 (0-65535)  or an I16 (-32767 - 32767).

Succes,

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 2
(2,809 Views)