Communication arduino MODBUS fails on high number of registers When I try to run the following program it runs ok:

#include &lt;modbus.h&gt;
#include &lt;modbusDevice.h&gt;
#include &lt;modbusRegBank.h&gt;
#include &lt;modbusSlave.h&gt;
#include &lt;LiquidCrystal.h&gt;


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
modbusDevice regBank;
modbusSlave slave;

void setup()
{
  lcd.begin(40, 2);
  regBank.setId(10);
  int numSet=0;
  for (int i=0; i &lt;= 300; i++){
    if (numSet &lt;= 8) {
      regBank.add(i);
    }
    if (numSet == 16) {
      numSet = 0;
    }
    numSet++;   
  }
  slave._device = &amp;regBank;
  slave.setBaud(9600);
}

void loop() {
  int numSet=0;
  for (int i=0; i &lt;= 300; i++){
    if (numSet &lt;= 8) {
        if (regBank.get(i) &gt;= 1) {
          lcd.setCursor(2, 0);
          lcd.print("test");                
        }
    }
    if (numSet == 16) {
      numSet = 0;
    }
    numSet++;   
  }
  slave.run();
}


But whenever I add more code, or raise the number of the loops, it starts failing to communicate over MODBUS.

Is it that some part of the Arduino can't handle the amount of work? It's confusing because it not only fails when adding more regBank.add() or regBank.get() actions, but also when adding more program code (for example add 40 lines of code to write to the LCD display).
Before you decided to switch platforms, take the time to figure out what your resource usage is. After compiling you'll get a report of the amount of memory you're consuming, check that first.

After that, it would be helpful if you could describe more clearly what you're seeing when the code fails.