Industrial Communications

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a hexadecimal 1D array to Packed ASCII in HART Communication protocol with LabVIEW

Solved!
Go to solution

I'm working on HART communication protocol with LabVIEW for my project. Here, I have to convert a hexadecimal 1D array to packed ascii to represent it as a readable format. I'm able to convert the hex 1D array to a string with Byte array to string function. But to convert it to Packed ASCII is where I got stuck. Attaching the VI for reference. The string I received after conversion is  ”PTÔ MMH7»(. But the Packed ASCII I need to get with the hex 1 D array is HARTTESTFRAMEALYST 7.2_

0 Kudos
Message 1 of 9
(774 Views)

@velaravind07 wrote:

Attaching the VI for reference.

There is no VI attached.

0 Kudos
Message 2 of 9
(770 Views)

Sorry again. Please ignore the previous attachment and check this one.

0 Kudos
Message 4 of 9
(762 Views)

(Please do not maximize the diagram and front panel to the screen, nobody likes to stare at 95% whitespace).

 

The algorithm for "packed ASCII" is quite simple. What have you tried?

 

(There is also this discussion, but the code is horrible and does not give the right result)

Message 5 of 9
(714 Views)
Solution
Accepted by topic author velaravind07

I am sure you figured it out by now, but here's a simple implementation.

 

altenbach_0-1727287725470.png

 

Message 6 of 9
(697 Views)

Typically, it is more efficient to operate bitwise (8x less memory compared to boolean arrays!), so here is one possibility. The result is the same:

 

altenbach_1-1727465327376.png

 

 

Message 7 of 9
(655 Views)

Thanks everyone for the support. I'm now able to convert the hexadecimal 1D array to Packed ASCII 

0 Kudos
Message 8 of 9
(615 Views)

@velaravind07 wrote:

Thanks everyone for the support. I'm now able to convert the hexadecimal 1D array to Packed ASCII 


 

Just to be clear about the semantics. The input array is packed ASCII (as byte array) while the output is just a plain string,

 

The shown code does NOT convert to "packed ASCII" but goes the other way (unpacking!). Of course it would be equally simple to implement the reverse operation if needed.

0 Kudos
Message 9 of 9
(505 Views)