Factory IO MODBUS CODESYS

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:

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.

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.

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.

I hope this helps

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.



Best regards,
Diluka.

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

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 (53.4 KB)
codesys.zip (273.2 KB)

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.

Once I used it in the program, it worked.

I hope this helps you.

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.

1 Like

You’re welcome! I’m glad it worked