# Codesys Modbus RTU - when are values read?

**URL:** <https://www.wago.community/t/codesys-modbus-rtu-when-are-values-read/1253>\
**Category:** CODESYS\
**Tags:** codesys, cc100\
**Created:** [October 14, 2024, 6:09am UTC](https://www.wago.community/t/codesys-modbus-rtu-when-are-values-read/1253 "2024-10-14T06:09:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sommerz](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@sommerz](https://www.wago.community/u/sommerz)\
**Post date:** [October 14, 2024, 6:09am UTC](https://www.wago.community/t/codesys-modbus-rtu-when-are-values-read/1253/1 "2024-10-14T06:09:06Z")

</div>

I’m working on a small project using a self designed modbus RTU board.

I have set up the modbus connection through the codesys modbus configurator, and use trigger variables to control when to read and write to the registers.  
I’m having some trouble with a register that I need to both read and write to.  
As it is right now, I trigger a read, look at the data, update the register and trigger a write. However, it seems like the register is read again every time the program loops around, without me triggering it.

Are there any resources that explain how codesys handles this stuff?

---

<div class="post-metadata">

**Author:** ![AdamReeve](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/adamreeve/32/59_2.png) [@AdamReeve](https://www.wago.community/u/AdamReeve)\
**Post date:** [October 15, 2024, 5:43pm UTC](https://www.wago.community/t/codesys-modbus-rtu-when-are-values-read/1253/2 "2024-10-15T17:43:57Z")

</div>

If most of your Modbus settings are left to default, the Modbus Channel is getting scanned cyclically. You can change that in the channel settings to “Application” so that you get programmatic control.

![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/0537a03a28c94c92e6cd3eba04e741dc5268d286.png)

This lets you use a function block from the auto-added IoDrvModbus library. This ModbusChannel function block is used to select the desired Modbus\_Slave, pick the Channel to operate, and then Execute the assigned Modbus function code.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/d0b78d4713c3f6fc39fb1fc7d931eab5b0935ce7.png)

I hope this helps!

–Adam
