# How to change type data word to float?

**URL:** <https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279>\
**Category:** Dashboard\
**Created:** [7 February 2024 02:55 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279 "2024-02-07T02:55:50Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 02:55 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/1 "2024-02-07T02:55:50Z")

</div>

I have successfully connected Mitsubishi PLC type Q to GX Work 2 and to node red using MC Read, the problem is that the output of MC Read for the feed address and speed is word data type, while for temperature the data type is float, I have tried to convert word to float using node funtion and also parser but it doesn't work, can anyone provide a solution?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2024 03:23 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/2 "2024-02-07T03:23:06Z")

</div>

I think maybe you should show us the output of MC Read, then perhaps we can suggest a solution.

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [7 February 2024 03:24 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/3 "2024-02-07T03:24:36Z")

</div>

Maybe this flow could help you.

[https://flows.nodered.org/flow/b9efdce94038df1bd742ddecde96a288/in/U7bo\_px1Nm6h](https://flows.nodered.org/flow/b9efdce94038df1bd742ddecde96a288/in/U7bo_px1Nm6h)

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 04:10 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/4 "2024-02-07T04:10:19Z")

</div>

this is the flow, for parses even though it has been connected it is still an error

 ![WhatsApp Image 2024-02-07 at 10.59.36](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/12a2a431b04185e76597711d1a97bd3e30c04ea7.jpeg)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 06:43 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/5 "2024-02-07T06:43:28Z")

</div>

Read the MC Read nodes built in help. It tells you how to return float values.

Example DFLOAT100 will request D100 as a float.

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 07:27 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/6 "2024-02-07T07:27:16Z")

</div>

thanks this way works, well it works for address D12277, but how come it doesn't work on D12266, on D12266 the value is even 0

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/badccfa1bc71d29a0d5569587d37b69f820aa49d.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 07:38 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/7 "2024-02-07T07:38:35Z")

</div>

> [@Sobri](#):
>
> but how come it doesn't work on D12266

Perhaps D12266 & D12267 are zero in the PLC?

Perhaps they are zeroed by another function before the end of the scan?

Try reading 2 WORD values from D12266 `DWORD12266,2`

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 07:41 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/8 "2024-02-07T07:41:35Z")

</div>

Btw, the reason you're original attempt does not work is you only read 1 16bit value from the PLC. A float is 32bit (2 WORDS)

and the parser shows an error because that is the last thing it encountered.

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 07:47 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/9 "2024-02-07T07:47:16Z")

</div>

The value is that, but in HMI it is 184.7

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/3/83a70bc467ebdb6d3f8a88ec9c87a4ac6ba14c82.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 08:03 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/10 "2024-02-07T08:03:51Z")

</div>

> [@Sobri](#):
>
> The value is that

Which value is what? Do the actual read from the PLC and show us the output in node-red as requested:

> [@Steve-Mcl](#):
>
> Try reading 2 WORD values from D12266 `DWORD12266,2`

Additionally, pull the value up in GX and show us that too.

  

> [@Sobri](#):
>
> but in HMI it is 184.7

Does the HMI read the address you you are queuing? Does the HMI do any internal conversion? What address and format does the HMI specify?

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 08:17 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/11 "2024-02-07T08:17:42Z")

</div>

in GX even the value does not come out when the PLC is running.  
This is from the beginning anyway, why do you think the GX work does not bring up the number when the engine is running?

 ![Screenshot (470)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c6794329b194f3ca6733b6375ae7046b54411d4.png)

and this is the result of using DWORD12266,2 di debug 5

 ![Screenshot (471)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd0e917935f66c70080cc633249e6b2efcebc8b9.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 08:39 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/12 "2024-02-07T08:39:48Z")

</div>

> [@Sobri](#):
>
> This is from the beginning anyway, why do you think the GX work does not bring up the number when the engine is running?
> 
> ![Screenshot (470)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c6794329b194f3ca6733b6375ae7046b54411d4.png)

You cannot rely on the view of a single function in the PLC. The value of a data memory can be updated many times throughout the scan of the PLC ladder. Usually it is the last operation that matters.

You need to view the whole data memory area (batch view or watch the 2 addresses)

> [@Sobri](#):
>
> and this is the result of using DWORD12266,2 di debug 5
> 
> ![Screenshot (471)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd0e917935f66c70080cc633249e6b2efcebc8b9.png)

Now you CAN feed the array of 2 values into a buffer parser but in reality you should cross reference the PLC to see what the final expected value is for that address. For example, it may be the intention of the ladder designer that the final result of this address is a float or a UINT that should be divided by 10 or some other variation

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 08:52 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/13 "2024-02-07T08:52:31Z")

</div>

then what should I do so that D12266 can turn into a float ? sorry I'm really a beginner.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 09:00 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/14 "2024-02-07T09:00:08Z")

</div>

You really need to understand the original intention. Is the value REALLY a float?

Just because someone has presented a value on a HMI that looks like a float does not mean it is an IEEE754 float. It could be an integer multiplied by 1000. It could be a made up format. It could be ASCII characters.

If you don't have access to the HMI source to trace where the value comes from and what format is specified, you could interrogate the ladder to infer the intention.

As a last resort, feed the 2 values into a parser and try different options like floatLE, floatBE, uint32LE, uint32BE, with & without swap16/ swap32 etc until you see a value similar to what you expect.

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [7 February 2024 09:08 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/15 "2024-02-07T09:08:43Z")

</div>

Thanks, I'll try it tomorrow when I work

---

<div class="post-metadata">

**Author:** ![Sobri](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@Sobri](https://discourse.nodered.org/u/Sobri)\
**Post date:** [8 February 2024 04:10 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/16 "2024-02-08T04:10:43Z")

</div>

This one I don't understand, but information from HMI, here is the type of data for D12266  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0234e76e4e48e9f574329636ccae3ab183c9eee.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 March 2024 04:11 UTC](https://discourse.nodered.org/t/how-to-change-type-data-word-to-float/85279/17 "2024-03-09T04:11:25Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
