Modbus timeout error rate is 30 ~ 40%.

I am using the modbus tool from

And arduino due is using the following code: Arduino/SimpleModbusSlaveArduino.ino at master · pepsilla/Arduino · GitHub

The code above works 100% without error.

However, integrating Modbus code from previously created code will result in timeout errors.

For example, if I send 8,000 times TX signals, I receive RX signals about 2000 times.

Response Timeout, Delay Between Polls, Connect Time, and Scan Rate were all set to 1000ms.

my loop() code is as follow :


    if (Flag03){
    else if (Flag04){
    else if(Flag05){
      holdingRegs[0] = 1234; // update data to be read

This entire loop runs in less than a second.
But, this code makes a lot of timeout error.

Always post complete code!

You must call modbus_update() in every run through loop(), at least several times a second. Most probably this is the reason for your timeouts. If your loop() needs almost a second to run and you even don't call modbus_update() in every run, it's not surprising that it doesn't work.