LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficient way to convery numeric HEX value to ASCII

Solved!
Go to solution

Hi,

Hope you are doing good,

 

I am trying to convert a decimal value- first to boolean array- break that array into smaller sub-arrays and then convert those sub-arrays into a a HEX value (numeric) (using a case structure I created to convert numeric values to HEX String) and then convert this Hex value into ASCII code.

 

I managed to get the desired output but I do not think it is the most efficient way to do it. I would appreciate if anyone has any recommendations. (VI attached)

 

Instructions I followed:

Xonmyth743_0-1620145741941.png

 

Screenshot for a quick glance: (VI attached)

Xonmyth743_1-1620145816696.png

 

 

0 Kudos
Message 1 of 6
(1,299 Views)

What is the desired output for the current diagram constant?

I don't see where you create a numeric. You only create a string.

Shouldn't your input be U16?

 

(I think what you need to do could fit on a postage stamp. No need for green or pink. Also learn the difference between datatype and cosmetic formatting)

0 Kudos
Message 2 of 6
(1,262 Views)
Solution
Accepted by XM43

I'm not even sure you are getting the right results.  You are flipping the arrays when I don't think you need to.  And I don't think you are supposed to convert into ASCII Hex and then back into an actual value.

 

Based on the chart you gave, I would do this:


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
Message 3 of 6
(1,260 Views)

@crossrulz wrote:

I'm not even sure you are getting the right results.  You are flipping the arrays when I don't think you need to.  And I don't think you are supposed to convert into ASCII Hex and then back into an actual value.

 

Based on the chart you gave, I would do this:


Hi crossrulz,

 

Thank you for looking into this. I was getting desired result for certain values not all of them. The constant I had in the block diagram were from an actual reading from the device and all the Alpha numeric (A1) values got converted as expected the numeric only (01) values were not.

 

But your implementation of course works with all types of input values and as expected. Thank you, I learned too many thing form this implementation.

 

0 Kudos
Message 4 of 6
(1,234 Views)

@altenbach wrote:

What is the desired output for the current diagram constant?

I don't see where you create a numeric. You only create a string.

Shouldn't your input be U16?

 

(I think what you need to do could fit on a postage stamp. No need for green or pink. Also learn the difference between datatype and cosmetic formatting)


Desired output was a string value. Yes, input should have been U16. I learned that while playing with the arrays.

I know my VI would have been painful for you to look at but I am trying to learn. So thank you for your input.

0 Kudos
Message 5 of 6
(1,230 Views)

Seriously thank you!! I learned that everything that I was doing could use split and/or join number functions and no more array conversions on the diagram and is all cleaned up. I did not know I could do this:

Xonmyth743_0-1620161617716.png

 

I could not take the before screenshot but that's actually healthy for viewers.

 

0 Kudos
Message 6 of 6
(1,217 Views)