# Convert 16 bit integer to Two Character ascii

**URL:** <https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143>\
**Category:** Ignition\
**Created:** [May 2, 2023, 1:00pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143 "2023-05-02T13:00:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:00pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/1 "2023-05-02T13:00:37Z")

</div>

I have a power meter that holds (4) Modbus registers for the device serial number that is ascii. Each register sends raw integer values for (2) ascii characters for its serial number. Is there a way to convert the integer in expression binding after pulling in the register tag to display the (2) ascii characters? For example, lets just start with ONE register that reads the following and we can call it (Tag33)

Raw Value Input Register 33 (Unsigned 16) = Tag33 = 17463  
Configure Expression Binding Code = toHex(Tag33) = 4437

ascii table for 44 = D (Which matches the device in first character)  
ascii table for 37 = 7 (Which matches the device in second character)  
How can I get Ignition to display D7 ?

---

<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:** [May 2, 2023, 1:04pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/2 "2023-05-02T13:04:28Z")

</div>

The modbus driver will do this for you with the `HRS` [address syntax](https://docs.inductiveautomation.com/display/DOC81/Modbus+Addressing#ModbusAddressing-ManuallyCreateanAddressforaSingleTag). {Well, `IRS` prefix for input registers.}

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 2, 2023, 1:09pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/3 "2023-05-02T13:09:51Z")

</div>

Yeah, probably easier to read the String, but if you had to make an expression:

```auto
char(({[~]Tag33} >> 8) & 0xFF) + char({[~]Tag33} & 0xFF)

```

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/4 "2023-05-02T13:12:39Z")

</div>

I have it pulled in to my Modbus register, have it now set to Holding Reg (Unsign16) but still yields 17463 any conversion I have tried with Expression Binding only yields the 4437.

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:13pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/5 "2023-05-02T13:13:03Z")

</div>

Modbus driver\*.....

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/6 "2023-05-02T13:16:09Z")

</div>

This worked!!! Thanks Kevin !!!

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:22pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/7 "2023-05-02T13:22:47Z")

</div>

@Kevin.Herron & @pturmel, If I were to read the String, how would I do that? In my "Device Connections" -\> "Modbus Type" I have Tag33 as Holding Register (UInt16). Am I missing anything?

@pturmel I see your message the address syntax shows an example "[DL240]HRS1024:20` Read 20 character string value starting at Holding Register 1024". Would I have "HRSTag33:2" ? If so, where would this go? I am new to Ignition, but have been able to pick things up quickly.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 2, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/8 "2023-05-02T13:27:16Z")

</div>

"Tag33" isn't a Modbus address. What is the underlying OPC Item Path for this tag?

If _that_ is "Tag33" it means you've set up an address mapping on the device config (recommend you don't do this) and need to go figure out the real address.

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:30pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/9 "2023-05-02T13:30:00Z")

</div>

Under Tag Browser, I have my Device, lets call it Unit10. From there I see my available tags populated from "Device Configuration". Under Unit10, I have Register 33.

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:31pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/10 "2023-05-02T13:31:55Z")

</div>

Under Register 33 there is a drop down menu, is this where I edit it?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 2, 2023, 1:33pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/11 "2023-05-02T13:33:17Z")

</div>

No, it sounds like you need to find this page in the Gateway: [Modbus Address Mapping - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Modbus+Address+Mapping)

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:34pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/12 "2023-05-02T13:34:26Z")

</div>

This is exactly what I have with all my registers I have pulled in through the Modbus Driver...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/0/00ef6ff99d38fc4acab6c121984c5e9ee772ffb4.png)

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:35pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/13 "2023-05-02T13:35:59Z")

</div>

Better yet, this is my screen shot of my Modbus Driver (sorry to confuse with the other image)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/c/5ce644058c85c61f1b85b0f64b612c99b8ff031c.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 2, 2023, 1:38pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/14 "2023-05-02T13:38:43Z")

</div>

Ok, delete all of that and let's do this the recommended way.

Just create 4 OPC tags in the Ignition Tag Browser. For the OPC Item Path, use an address like:

- `[DeviceName]10.HR33`
- `[DeviceName]10.HR34`
- `[DeviceName]10.HR35`
- `[DeviceName]10.HR36`

Alternatively, the String approach:

- `[DeviceName]10.HRS33:8`

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:40pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/15 "2023-05-02T13:40:47Z")

</div>

OK, I think I am understanding this now. I was hopeful that I didn't need to create a tag and just pull in the register with it being converted and be done. Let me try this and I will get back to the thread shortly. Thanks!!!

---

<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:** [May 2, 2023, 1:42pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/16 "2023-05-02T13:42:42Z")

</div>

> [@Tyler\_Dixon](#):
>
> pull in the register with it being converted and be done

That's the "String approach". Highly recommended.

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:51pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/17 "2023-05-02T13:51:05Z")

</div>

Am I confusing the "String approach" with my Modbus Type when pulling it in under "Device Configuration" as Holding Register (UInt16) ? Here is a screen shot if you haven't seen the other post...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/c/5ce644058c85c61f1b85b0f64b612c99b8ff031c.png)

---

<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:** [May 2, 2023, 1:54pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/18 "2023-05-02T13:54:19Z")

</div>

Kevin's advice, and mine too, is to not use the mappings in the Device Configuration section **at all**. Use explicit OPC item paths in your Ignition tags.

If you simply cannot live without browsing your device registers, consider [my alternate driver](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-advanced-modbus).

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 1:58pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/19 "2023-05-02T13:58:33Z")

</div>

OK. I will create the OPC tag path.

---

<div class="post-metadata">

**Author:** ![Tyler\_Dixon](https://avatars.discourse-cdn.com/v4/letter/t/e56c9b/32.png) [@Tyler\_Dixon](https://forum.inductiveautomation.com/u/Tyler_Dixon)\
**Post date:** [May 2, 2023, 2:22pm UTC](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143/20 "2023-05-02T14:22:30Z")

</div>

@Kevin.Herron & @pturmel, I am getting a "Bad\_NodeID Unknown" error configuration message. Here is my 33 reg Tag Editor properties screen shot...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/caa6981ebf71598dc612f36ee17948f3a5151333.png)

[Next page](https://forum.inductiveautomation.com/t/convert-16-bit-integer-to-two-character-ascii/73143.md?page=2)
