so here's your project source files: mike-project-timing.zip
Let's see what you have done...
Here's the same in PDF if you prefer: rexygen-project-timing.pdf
The first thing to understand is the allocation of time slots for individual tasks and drivers:
- Base tick = 20 ms
- RPI - Raspberry Pi driver, factor = 1, i.e. execution period = 20 ms
- MBM - Modbus RTU master, factor = 5, i.e. execution period = 100 ms
- modbus_write_task, start = 0, stop = 1, factor = 3, i.e. execution period = 600 ms
- modbus_read_task, start = 1, stop = 2, factor = 10, i.e. execution period = 2000 ms
The diagram above only illustrates the time slots. It does not show how long each task executes and when exactly it happens.
From what you wrote, I believe it's important to note that it's the yellow Modbus driver where the data is actually sent and received. Therefore all the Modbus registers which you have defined in the Modbus driver configuration for reading, will be read every 100ms. However, your modbus_read_task is scheduled to execute with 2 second period, therefore 9 out of 10 readings will be in fact wasted, creating unnecessary traffic on the serial bus.
Also keep in mind that by default, Modbus write commands are executed only when there is some change to write. The Modbus driver takes care of this for you to preserve bandwidth.
Is this clear to read so far? Learned something new? Willing to continue? Let me know...
I believe you could achieve what you need even with a single task, but I might be misleaded by the project source files reduced to the absolute minimum.