LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove two leading zeros from hex string

Solved!
Go to solution

I am passing a ASCII string from Test Stand to a VI i wrote and I start out with "04" and my VI get the ASCII "04" normal.  I then convert  a ASCII string to a Hex string (using a VI solution I found on the web) and instead of it being Hex Display "04", it adds two leading zeros in the Hex  Display "0004".  I need to remove the two leading zeros so it is just "04".  I am sure there is probably a obvious solution (I am rather new at LabVIEW). Thank you

0 Kudos
Message 1 of 9
(6,082 Views)

String palette >> String Subset

 

Better yet, fix the VI you found on the web that is giving you the extra zeroes.

0 Kudos
Message 2 of 9
(6,079 Views)

Could you supply the code that you are doing the conversion with?  We will likely find your problem there.


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 3 of 9
(6,078 Views)

There is probably much more going on than it "just adding two extra zeroes" that you need to chop off.  Find out what's really going on so you don't make the mistake of treating the symptom and not the cause.  (I can pretty much guarantee that chopping off the extra zeroes without understanding why will lead to heartache down the road.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 9
(6,041 Views)

I think this conversion does what you are looking for.


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 5 of 9
(6,007 Views)

One thing I left out.  The VI works fine by it self, when I input a 04 string in Hex Display.

The problem is that I am passing a 04 string from TestStand, it shows up as the Hex value 34 (Hex Display), not the symbol 04 (Hex Display).  This is where I added the Hex convert section where is converts to 0004 (Hex Display) but I need it to be 04.  The convert program does converts the string 17FF (Normal Display) to 17FF (Hex Display) correctly, it just has a problem a 04 (2 digits) vs17FF (4 digits).

I then pass the concatenated string to a microprocessor.Labview_VI.jpg

0 Kudos
Message 6 of 9
(5,998 Views)
Solution
Accepted by topic author PO1

Wiring a format statement to a typecast operation just confuses the programer. Don't do that. The value is not important, just the type. (...and if you want a string, you don't even need to wire the type. String is the default!)

 

What is the representation of the blue zero diagram constant wired to the bottom left of "hex string to munber"? Make sure it is U8.

 

Please attach the actual VI, many things cannot be determine by a picture alone. Thanks!

0 Kudos
Message 7 of 9
(5,995 Views)

Changing  the 0 from U16 to U8 fixed it.

I can't believe it was that easy - I won't make that mistake again.

I will also look into the programming issue you pointed out.

Thank you, ( Kudos)

Paul

 

0 Kudos
Message 8 of 9
(5,962 Views)

Well, this shows you why code images are not useful for troubleshooting.

There is no way to tell what the representation of these constants is! 😄

Message 9 of 9
(5,942 Views)