# Data conversion

**URL:** <https://forum.inductiveautomation.com/t/data-conversion/81949>\
**Category:** Ignition\
**Created:** [November 15, 2023, 7:24pm UTC](https://forum.inductiveautomation.com/t/data-conversion/81949 "2023-11-15T19:24:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [November 15, 2023, 7:24pm UTC](https://forum.inductiveautomation.com/t/data-conversion/81949/1 "2023-11-15T19:24:05Z")

</div>

I am getting some data through A Modbus/TCP connection. The data that is coming through is a decimal number. I need to be able to take this decimal number convert it to hex, swap the order convert it to an ASCII hex value and save the resulting string.  
Any ideas on the best way to take the decimal and convert it to the ASCII value?  
Below is what I received from the manufacturer as to the conversion process. The numbers are the actual data I am receiving  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/2/a2aa3c56fa74a0a8acc03f127743819e71d656b2.jpeg)  
This is my actual data  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/d/5d5a99dc22c7bbdc4c502766325c1abc887116d9.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 15, 2023, 7:41pm UTC](https://forum.inductiveautomation.com/t/data-conversion/81949/2 "2023-11-15T19:41:46Z")

</div>

Did you try to edit the Gateway | Config | OPC UA | Device Connections | Modbus TCP connection | Advanced | Reverse Word Order?

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [November 15, 2023, 7:58pm UTC](https://forum.inductiveautomation.com/t/data-conversion/81949/3 "2023-11-15T19:58:03Z")

</div>

yeah had no effect because the data is a decimal which needs to be converted to hex before swapping

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [November 15, 2023, 8:10pm UTC](https://forum.inductiveautomation.com/t/data-conversion/81949/4 "2023-11-15T20:10:47Z")

</div>

You can use a simple expression to do the conversion for you.

```auto
char({Value} & 0xFF) + char(({Value} & 0xFF00) >> 8)

```

For the value `19523` this expression would return `CL`. You could of course extend this to include all of the potential registers. I would probably recommend using expression tags however.

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [November 15, 2023, 8:35pm UTC](https://forum.inductiveautomation.com/t/data-conversion/81949/5 "2023-11-15T20:35:26Z")

</div>

HOT DANG!!!! That works like a charm!! TY!!!!!!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 16, 2023, 1:12am UTC](https://forum.inductiveautomation.com/t/data-conversion/81949/6 "2023-11-16T01:12:59Z")

</div>

If @lrose's solution worked, then IA's native conversion `HRS` should work, too, without the funky expressions, and **with** write support. (With **byte** swapping, perhaps.)
