01-14-2014
02:16 PM
- last edited on
06-10-2025
10:11 AM
by
Content Cleaner
I am working on a project to convert HEX values to ASCII. Instead of getting in over my head, I figured I'd play and get myself familiar with Hex conversions. I googled "hex to ascii labview" and I came to the link below to get me started:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGwnCAG&l=en-US
I've done exactly what it states in the web document, but when type a letter (I've used the letter L) & run the VI, I keep getting three \00 in the ASCII output when I turn on Codes display. Is this normal behavior? I'm working in LabView 2012.
01-14-2014 02:34 PM
It is because you are converting to an I32, which uses 4 bytes. Therefore the output must be 4 bytes in length. The \00 just means that those bytes have a value of 0 (NULL).
Maybe you should describe a little better exactly what you are trying to do. Where do the characters come from? Why convert to ASCII? I have a feeling we can simplify your life by quite a bit if we had that information.
01-14-2014 03:44 PM
Well, looking at the documentation (starts on page 36), I THINK it's hexadecimal. I'm now having second thoughts.
I apologize, this is my first dip into this kinda stuff. I am used to serial commands, but nothing like this so I apologize for my ignorance.
01-14-2014 03:56 PM - edited 01-14-2014 04:25 PM
All you get is a binary string with 10 bytes. Use string to byte array and then index out all the desired values. You can create a lookup table to translate each value into the huma readable meaning as listed in the manual.
If you request a measurement, you get 5 bytes back, but this is already formatted in decimal. No conversion needed, just trim the x00 termination character.
01-15-2014 04:35 PM
Something like this? Also, where are you getting the 10 bytes from? And the 5?
01-15-2014 05:26 PM - edited 01-15-2014 05:28 PM
@Eric1977 wrote:
Something like this? Also, where are you getting the 10 bytes from? And the 5?
from the manual you had attached. 😄
Note that if you read a value, it is already formatted as a decimal string. Simply take the string subset of the first four bytes or scan into a to DBL if you want it as a numeric type.
01-16-2014 07:09 AM
OK, I'll admit, I'm lost. This is the first time doing a hexidecimal conversion. Maybe if I seen a example of what your talking about, the concept(s) might sink in.
01-16-2014 08:46 AM - edited 01-16-2014 08:46 AM
Can you attach some raw sample strings received from the instrument?
05-15-2014
11:24 AM
- last edited on
06-10-2025
10:11 AM
by
Content Cleaner
As crossrulz mentioned, only one byte of the "Char" is used. See this example for an explanation and a solution to get rid of the null character:
https://forums.ni.com/t5/Example-Code/Using-the-LabVIEW-Key-Down-Event/ta-p/3996186
To quote the note in the example:
-Carl