# Factory IO MODBUS CODESYS

**URL:** https://community.factoryio.com/t/factory-io-modbus-codesys/3127
**Category:** Support
**Created:** [August 16, 2024, 11:21am UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127 "2024-08-16T11:21:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dilukamdp](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@dilukamdp](https://community.factoryio.com/u/dilukamdp)
#### Post date: [August 16, 2024, 11:21am UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/1 "2024-08-16T11:21:00Z")

</div>

Hello there,

I would like to read float/int data from CODESYS simulator side. Although I can communicate via discrete i/o using sentos’s approach shown:

> [@Help with modbus TCP/IP Client "Talking" to Codesys V3.5](https://community.factoryio.com/t/help-with-modbus-tcp-ip-client-talking-to-codesys-v3-5/655/3):
>
> Hi @thasamm, Are you using SP16 or higher? If so, CODESYS suffered some changes, so try this: Check the “Discrete Bit Areas” box under ModbusTCP\_Slave\_Device \> General \> Configured Parameters and write the number of Coils and Discrete Inputs you need, as shown in the image below. Map the variables (using Coils and Discrete Inputs). Map these variables in FIO. We’ll release a tutorial regarding these alterations. Meanwhile, …

I can’t do that for float/int. Could anyone pls help me how to configure that. I’m using CODESYS 3.5 sp 20.

Thanks.

---

<div class="post-metadata">

### Author: ![adriana.silva](https://dub1.discourse-cdn.com/flex017/user_avatar/community.factoryio.com/adriana.silva/32/752_2.png) [@adriana.silva](https://community.factoryio.com/u/adriana.silva)
#### Post date: [August 26, 2024, 9:12am UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/2 "2024-08-26T09:12:55Z")

</div>

Hello @dilukamdp

To get Float and Int types, you can use either Holding Registers or Input Registers.  
You just have to be aware that you must use a scale factor to correctly communicate the values. This is described in the documentation page about the Modbus driver in the Scale field, available here: [Modbus TCP/IP Client - FACTORY I/O](https://docs.factoryio.com/manual/drivers/modbus-client/#configuration).

Note that when using Modbus, Factory I/O scales Float values by 100, converts it to an integer, and sends it in a Word. In Codesys you have to convert this Word to a Real and divide it by 100 to get the correct value. Note that Factory I/O’s Float and Int data types correspond to Real and DInt in Codesys.

In Codesys you have to map the variables using the Holding Registers and the Input Registers. just like you did to the discrete I/Os.

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/factoryio/original/1X/092c46b7cded960b909cb59392f4394d9b4e365f.png)

I hope this helps

---

<div class="post-metadata">

### Author: ![dilukamdp](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@dilukamdp](https://community.factoryio.com/u/dilukamdp)
#### Post date: [September 5, 2024, 7:46am UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/3 "2024-09-05T07:46:35Z")

</div>

Hi Adriana,  
Thank you so much for the reply. I only had time today to take a look at this issue again.

Unfortunately I didn’t manage to get it fixed yet. I declared a WORD type global variable and mapped it as shown in the attached screenshots. However, that variable does not still get updated from FIO side for some reason (digital inputs get updated when declared as coils and discrete inputs as shown). In case if you have any feedback I truly appreciate it again.

I have attached screenshots of my configurations in CODESYS and FIO side for your reference.

 ![Screenshot 2024-09-05 173716](https://europe1.discourse-cdn.com/flex017/uploads/factoryio/original/1X/7e14f33010d9c7aa9ad50c0407e797e923465ec1.jpeg)  
 ![Screenshot 2024-09-05 173757](https://europe1.discourse-cdn.com/flex017/uploads/factoryio/original/1X/9e382848abf2a23125aeba2986afeb10d1e303eb.png)  
 ![Screenshot 2024-09-05 173905](https://europe1.discourse-cdn.com/flex017/uploads/factoryio/original/1X/00e6b5b00bbf0fd4e3e687902a3b8f62cad63457.png)

Best regards,  
Diluka.

---

<div class="post-metadata">

### Author: ![adriana.silva](https://dub1.discourse-cdn.com/flex017/user_avatar/community.factoryio.com/adriana.silva/32/752_2.png) [@adriana.silva](https://community.factoryio.com/u/adriana.silva)
#### Post date: [September 5, 2024, 9:09am UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/4 "2024-09-05T09:09:13Z")

</div>

Hi @dilukamdp

From the images everything seems to be well configured and I can’t see what might be happening. Can you share your project so I can take a closer look and try to see what’s issue?  
You can share it here or send it to our support email: support at realgames dot pt

---

<div class="post-metadata">

### Author: ![dilukamdp](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@dilukamdp](https://community.factoryio.com/u/dilukamdp)
#### Post date: [September 5, 2024, 12:39pm UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/6 "2024-09-05T12:39:03Z")

</div>

Hi Adriana,

It seems that my earlier attachment contains all temp files as well and antivirus software seems to complain about opening it. Kindly find only the essential project files for CODESYS and FactoryIO. Thank you for your support.

Best regards,  
Diluka.  
[Sep5Proj.factoryio](https://community.factoryio.com/uploads/short-url/x27gA4YNat8KlLCTCnBolWXzzbg.factoryio) (53.4 KB)  
[codesys.zip](https://community.factoryio.com/uploads/short-url/o5ljSSO92r7Dwu0nNa305MyVXMW.zip) (273.2 KB)

---

<div class="post-metadata">

### Author: ![adriana.silva](https://dub1.discourse-cdn.com/flex017/user_avatar/community.factoryio.com/adriana.silva/32/752_2.png) [@adriana.silva](https://community.factoryio.com/u/adriana.silva)
#### Post date: [September 5, 2024, 12:53pm UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/7 "2024-09-05T12:53:54Z")

</div>

Hi @dilukamdp

Thank you for sharing your project.  
I’ve opened it, and it seems that the values don’t reach Codesys because you are not using the variable in your program.

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/factoryio/original/1X/28ab3686bffb2f5ef097cfab3986236019c4d6c9.png)

Once I used it in the program, it worked.

I hope this helps you.

---

<div class="post-metadata">

### Author: ![dilukamdp](https://avatars.discourse-cdn.com/v4/letter/d/85e7bf/32.png) [@dilukamdp](https://community.factoryio.com/u/dilukamdp)
#### Post date: [September 5, 2024, 1:26pm UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/8 "2024-09-05T13:26:13Z")

</div>

Hi Adriana,

Thanks so much. As you noted, once I used the variable within the program it started working. I really appreciate the prompt response and support provide.

Best regards,  
Diluka.

---

<div class="post-metadata">

### Author: ![adriana.silva](https://dub1.discourse-cdn.com/flex017/user_avatar/community.factoryio.com/adriana.silva/32/752_2.png) [@adriana.silva](https://community.factoryio.com/u/adriana.silva)
#### Post date: [September 5, 2024, 1:48pm UTC](https://community.factoryio.com/t/factory-io-modbus-codesys/3127/9 "2024-09-05T13:48:56Z")

</div>

You’re welcome! I’m glad it worked
