# 64-Bit Double Little Endian Input Register

**URL:** <https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987>\
**Category:** Ignition\
**Created:** [May 20, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987 "2023-05-20T13:12:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/1 "2023-05-20T13:12:46Z")

</div>

Okay, I'm stuck. I'm trying to do a Modbus TCP read from a device only has 64-Bit Double Little Endian Input Registers. Modbus Poll can bring in the data correctly when selecting the data format as 64-Bit Double Little Endian but Ignition does not when doing a "Input Register Double" with a direct Modbus Address. I've tried doing [Device]1.IRD30001 with data type set to Double and tried [Device]1.IR30001 with data type set to Double. I've tried swapping the word order on the Device Connection as well.

I've also tried to do four individual integer reads and then created an expression tag to bring all four words in and changing around the word order with "stringFormat("%d%d%d%d", {[~]1\_IRD30001}, {[~]1\_IRD30002}, {[~]1\_IRD30003}, {[~]1\_IRD30004})".

Any other suggestions out there? The closest I've found on Ignition is the Omron Fins driver with setting the type as @LE but that failed.

I get values from most of the ways I've tried but just not the correctly formatted value...

Here is the register map from the manufacturer:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/142e240dbed739c64f6da3b05025c262686c98ee.jpeg)

---

<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 20, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/2 "2023-05-20T13:16:21Z")

</div>

> [@jasonpdavid](#):
>
> I've also tried to do four individual integer reads and then created an expression tag to bring all four words in and changing around the word order with "stringFormat("%d%d%d%d", {[~]1\_IRD30001}, {[~]1\_IRD30002}, {[~]1\_IRD30003}, {[~]1\_IRD30004})".

This is probably the approach you need, except string formatting doesn't do what you want. You need to use bitwise operators to combine the 4 registers.

edit: ooph, nevermind, it's actually a little trickier because it's a Float/Double and not a Long... will require scripting... hang on.

---

<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 20, 2023, 1:30pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/3 "2023-05-20T13:30:19Z")

</div>

Okay... you need a script in a library like this:

```auto
def double_le(w1, w2, w3, w4):
	from java.lang import Double
	bits = w1 | (w2 << 16) | (w3 << 32) | (w4 << 48)

	return Double.longBitsToDouble(bits)

```

Then you can either call this however you like, or use `runScript` on an expression tag like:

```auto
runScript("ByteUtil.double_le", 0, {[~]W1}, {[~]W2}, {[~]W3}, {[~]W4})

```

If you need to write to the tag also you'll have to do the inverse of this, using [`doubleToLongBits`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Double.html#doubleToLongBits(double))... it's not pretty.

@pturmel's Modbus driver probably natively supports reading this type.

edit: also, you'd address each register/word as `IR`, not `IRD`.

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 1:41pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/4 "2023-05-20T13:41:54Z")

</div>

Would the data type for each tag still be Double with the IR? How about the final tag data type? I just tried your suggestion on an expression tag and it returns Error\_ExpressionEval

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5fbaaf2290c9dd5de35d4f82638ed91f00d91bce.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 20, 2023, 1:42pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/5 "2023-05-20T13:42:41Z")

</div>

No, the intermediate tags would be Integer, the final expression tag would be Double.

---

<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 20, 2023, 1:45pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/6 "2023-05-20T13:45:18Z")

</div>

Before you go further, set your device to zero-based addressing, and drop the '3' prefix. So, `1.IRD0`, `1.IRD4`, and so on.

---

<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 20, 2023, 1:46pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/7 "2023-05-20T13:46:31Z")

</div>

> [@pturmel](#):
>
> and drop the '3' prefix.

Didn't want to get into whether this was necessary yet... he does seem to be getting values at `30001` etc... 5 digit addressing is ambiguous 🙄

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 1:47pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/8 "2023-05-20T13:47:39Z")

</div>

Same error on the expression tag.

---

<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 20, 2023, 1:49pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/9 "2023-05-20T13:49:37Z")

</div>

Did you create a script in the library called "ByteUtils" and add that function? Is your "Gateway Scripting Project" set to the project containing this library?

[https://docs.inductiveautomation.com/display/DOC81/Project+Library#ProjectLibrary-GatewayScriptingProject](https://docs.inductiveautomation.com/display/DOC81/Project+Library#ProjectLibrary-GatewayScriptingProject)

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 1:56pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/10 "2023-05-20T13:56:34Z")

</div>

I did not...sorry. Added to the Project Library now as you wrote it with the W1, W2... Pardon my ignorance but do I need to change those to a tag reference in the Project Library? And how does the runScript ` {[~]W1}` need to be changed to reference each tag?

---

<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 20, 2023, 1:58pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/11 "2023-05-20T13:58:13Z")

</div>

Your runScript looks fine, it should use your actual tag names.

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 2:13pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/12 "2023-05-20T14:13:56Z")

</div>

Still getting the error. The link to the manual refers to placing the project name in the Gateway Settings but I am not seeing a field for Gateway Scripting Project to place the project name.  
I'm sure I'm still doing something wrong...

Thanks for all the help on a Saturday morning! You as well @pturmel

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/c/bc9165e986c7d1b15e71acf594e56bff10bbe9fd.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 20, 2023, 2:22pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/13 "2023-05-20T14:22:41Z")

</div>

Hmm, might not be necessary on Edge since there is only 1 project.

What is the error in the tag diagnostics?

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 2:24pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/14 "2023-05-20T14:24:27Z")

</div>

Update: Error\_TypeConversion("Invalid value: Tag value is Infinity or NaN.")  
In the Script Console it works to output a value when I define the w1..etc with integers manually but I get nan if any of the values entered are a negative.

---

<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 20, 2023, 2:25pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/15 "2023-05-20T14:25:41Z")

</div>

There should be more details with it.

I plugged in your numbers and see, though:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/1/71733c9271b4302326bee50496619ef16e3866f4.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 20, 2023, 2:27pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/16 "2023-05-20T14:27:08Z")

</div>

Try this change to the script:

```auto

def double_le(w1, w2, w3, w4):
	from java.lang import Double
	bits = (w1 & 0xFFFF) | ((w2 << 16) & 0xFFFF) | ((w3 << 32) & 0xFFFF) | ((w4 << 48) & 0xFFFF)

	return Double.longBitsToDouble(bits)

```

Now I get a very very small value that shows as 0 in the tag browser unless you double click.

---

<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 20, 2023, 2:30pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/17 "2023-05-20T14:30:11Z")

</div>

If you can show me exactly what Mod Poll reads and the value it ends up with that will help.

---

<div class="post-metadata">

**Author:** ![jasonpdavid](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jasonpdavid](https://forum.inductiveautomation.com/u/jasonpdavid)\
**Post date:** [May 20, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/18 "2023-05-20T14:37:12Z")

</div>

I can't tunnel in using ModPoll while remote so I'm not sure what the current values are. I'm pulling in 5 registers with temperature being one of them. I'm trying the other register groups now but I'm getting the small 0 value on all attempts so far.

---

<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 20, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/19 "2023-05-20T14:37:57Z")

</div>

I think my script is wrong, it's rearranging the _word_ order, not the byte order.

---

<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 20, 2023, 2:45pm UTC](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/20 "2023-05-20T14:45:10Z")

</div>

Maybe something like this instead:

```auto
def double_le2(value):
	from java.lang import Double
	b0 = (value >> 56) & 0xFF
	b1 = (value >> 48) & 0xFF
	b2 = (value >> 40) & 0xFF
	b3 = (value >> 32) & 0xFF
	b4 = (value >> 24) & 0xFF
	b5 = (value >> 16) & 0xFF
	b6 = (value >> 8) & 0xFF
	b7 = (value >> 0) & 0xFF
	
	return Double.longBitsToDouble(b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7)

```

and you only pass in 1 tag, not 4, addressed as `IRI_6430001`.

[Next page](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987.md?page=2)
